pub fn parse(&mut self, width: usize) -> Result<()> {
        // replace a tab character by 4 spaces
        // as it's possible that the terminal cannot render the tab character
        self.content = self.content.replace("\t", "    ");

        debug!(
            "parse article (url={}), width: {}, content: {}",
            self.url, width, self.content
        );

        // parse HTML content into DOM node(s)
        let dom = parse_document(RcDom::default(), Default::default())
            .from_utf8()
            .read_from(&mut (self.content.as_bytes()))?;

        let mut s = StyledString::new();
        let mut links = vec![];
        Self::parse_dom_node(
            dom.document,
            width,
            &mut s,
            &mut links,
            Style::default(),
            false,
            true,
            String::new(),
        );

        self.parsed_content = s;

        // process the links inside the article
        self.links = links
            .into_iter()
            .map(|l| {
                match url::Url::parse(&l) {
                    // failed to parse the link, possibly a relative link, (e.g `/a/b`)
                    Err(_) => match url::Url::parse(&self.url).unwrap().join(&l) {
                        Ok(url) => url.to_string(),
                        Err(_) => String::new(),
                    },
                    Ok(_) => l,
                }
            })
            .collect();

        Ok(())
    }
/// Parse article's content (in HTML) into a styled text depending on
/// the application's component styles and the HTML tags
Parse article's content (in HTML) into a styled text depending on
the application's component styles and the HTML tags
Parse article ' s content ( in HTML ) into a styled text depending on the application ' s component styles and the HTML tags
pub fn parse(&mut self, width: usize) -> Result<()> {
        // replace a tab character by 4 spaces
        // as it's possible that the terminal cannot render the tab character
        self.content = self.content.replace("\t", "    ");
        debug!(
            "parse article (url={}), width: {}, content: {}",
            self.url, width, self.content
        );
        // parse HTML content into DOM node(s)
        let dom = parse_document(RcDom::default(), Default::default())
            .from_utf8()
            .read_from(&mut (self.content.as_bytes()))?;
        let mut s = StyledString::new();
        let mut links = vec![];
        Self::parse_dom_node(
            dom.document,
            width,
            &mut s,
            &mut links,
            Style::default(),
            false,
            true,
            String::new(),
        );
        self.parsed_content = s;
        // process the links inside the article
        self.links = links
            .into_iter()
            .map(|l| {
                match url::Url::parse(&l) {
                    // failed to parse the link, possibly a relative link, (e.g `/a/b`)
                    Err(_) => match url::Url::parse(&self.url).unwrap().join(&l) {
                        Ok(url) => url.to_string(),
                        Err(_) => String::new(),
                    },
                    Ok(_) => l,
                }
            })
            .collect();
        Ok(())
    }
pub fn parse ( & mut self , width : usize ) -> Result < ( ) > { // replace a tab character by 4 spaces // as it's possible that the terminal cannot render the tab character self . content = self . content . replace ( " \t " , " " ) ; debug ! ( " " self url width self content ) ; // parse HTML content into DOM node(s) let dom = parse_document ( RcDom :: default ( ) , Default :: default ( ) ) . from_utf8 ( ) . read_from ( & mut ( self . content . as_bytes ( ) ) ) ? ; let mut s = StyledString :: new ( ) ; let mut links = vec ! [ ] ; Self :: parse_dom_node ( dom . document , width , & mut s , & mut links , Style :: default ( ) , false , true , String :: new ( ) , ) ; self . parsed_content = s ; // process the links inside the article self . links = links . into_iter ( ) . map ( | l | { match url :: Url :: parse ( & l ) { // failed to parse the link, possibly a relative link, (e.g `/a/b`) Err ( _ ) => match url :: Url :: parse ( & self . url ) . unwrap ( ) . join ( & l ) { Ok ( url ) => url . to_string ( ) , Err ( _ ) => String :: new ( ) , } , Ok ( _ ) => l , } } ) . collect ( ) ; Ok ( ( ) ) }
Parse article's content (in HTML) into a styled text depending on
the application's component styles and the HTML tags
Parse article ' s content ( in HTML ) into a styled text depending on the application ' s component styles and the HTML tags
&mut self
width
usize