1- use super :: html:: HTMLParsedResult ;
1+ use super :: html:: HTMLTextParsedResult ;
22use super :: rcdom:: { Handle , NodeData , RcDom } ;
33use crate :: parser:: html:: HTMLTableParsedResult ;
44use crate :: prelude:: * ;
@@ -40,7 +40,7 @@ impl Article {
4040 /// # Arguments:
4141 /// * `max_width`: the maximum width of the parsed content. This is mostly used
4242 /// to construct a HTML table using `comfy_table`.
43- pub fn parse ( & self , max_width : usize ) -> Result < HTMLParsedResult > {
43+ pub fn parse ( & self , max_width : usize ) -> Result < HTMLTextParsedResult > {
4444 debug ! ( "parse article ({:?})" , self ) ;
4545
4646 // parse HTML content into DOM node(s)
@@ -90,21 +90,21 @@ impl Article {
9090 base_link_id : usize ,
9191 mut style : Style ,
9292 mut args : ArticleParseArgs ,
93- ) -> ( HTMLParsedResult , bool ) {
93+ ) -> ( HTMLTextParsedResult , bool ) {
9494 // TODO: handle parsing <ol> tags correctly
9595
9696 debug ! (
9797 "parse dom node: {:?}, style: {:?}, args: {:?}" ,
9898 node, style, args
9999 ) ;
100100
101- let mut result = HTMLParsedResult :: default ( ) ;
101+ let mut result = HTMLTextParsedResult :: default ( ) ;
102102 let mut suffix = StyledString :: new ( ) ;
103103
104104 let mut visit_block_element_cb = || {
105105 if !args. is_first_element_in_block {
106- result. s . append_plain ( "\n \n " ) ;
107- result. s . append_styled ( & args. prefix , style) ;
106+ result. content . append_plain ( "\n \n " ) ;
107+ result. content . append_styled ( & args. prefix , style) ;
108108 }
109109 args. is_first_element_in_block = true ;
110110 } ;
@@ -128,7 +128,7 @@ impl Article {
128128
129129 has_non_ws_text |= !text. trim ( ) . is_empty ( ) ;
130130
131- result. s . append_styled ( text, style) ;
131+ result. content . append_styled ( text, style) ;
132132 }
133133 NodeData :: Element {
134134 ref name,
@@ -151,7 +151,9 @@ impl Article {
151151 style = style. combine ( component_style. header ) ;
152152 }
153153 expanded_name ! ( html "br" ) => {
154- result. s . append_styled ( format ! ( "\n {}" , args. prefix) , style) ;
154+ result
155+ . content
156+ . append_styled ( format ! ( "\n {}" , args. prefix) , style) ;
155157 }
156158 expanded_name ! ( html "p" ) => visit_block_element_cb ( ) ,
157159 expanded_name ! ( html "code" ) => {
@@ -169,15 +171,15 @@ impl Article {
169171
170172 style = style. combine ( component_style. multiline_code_block ) ;
171173
172- result. s . append_styled ( " " , style) ;
174+ result. content . append_styled ( " " , style) ;
173175 }
174176 expanded_name ! ( html "blockquote" ) => {
175177 visit_block_element_cb ( ) ;
176178
177179 args. prefix = format ! ( "{}▎ " , args. prefix) ;
178180 style = style. combine ( component_style. quote ) ;
179181
180- result. s . append_styled ( "▎ " , style) ;
182+ result. content . append_styled ( "▎ " , style) ;
181183 }
182184 expanded_name ! ( html "table" ) => {
183185 let mut table_result = HTMLTableParsedResult :: default ( ) ;
@@ -211,7 +213,7 @@ impl Article {
211213 table. add_row ( row. into_iter ( ) . map ( |c| c. source ( ) . to_owned ( ) ) ) ;
212214 }
213215
214- result. s . append_styled ( format ! ( "\n \n {table}" ) , style) ;
216+ result. content . append_styled ( format ! ( "\n \n {table}" ) , style) ;
215217
216218 return ( result, true ) ;
217219 }
@@ -225,7 +227,7 @@ impl Article {
225227 args. is_first_element_in_block = true ;
226228
227229 result
228- . s
230+ . content
229231 . append_styled ( format ! ( "\n {}• " , args. prefix) , style) ;
230232 }
231233 expanded_name ! ( html "img" ) => {
@@ -240,10 +242,12 @@ impl Article {
240242 } ;
241243
242244 if !args. is_first_element_in_block {
243- result. s . append_plain ( "\n \n " ) ;
245+ result. content . append_plain ( "\n \n " ) ;
244246 }
245- result. s . append_styled ( & img_desc, style) ;
246- result. s . append_styled ( " (image)" , component_style. metadata ) ;
247+ result. content . append_styled ( & img_desc, style) ;
248+ result
249+ . content
250+ . append_styled ( " (image)" , component_style. metadata ) ;
247251 }
248252 expanded_name ! ( html "a" ) => {
249253 // find `href` attribute of an <a> tag
@@ -291,7 +295,7 @@ impl Article {
291295 }
292296 } ) ;
293297
294- result. s . append ( suffix) ;
298+ result. content . append ( suffix) ;
295299 ( result, has_non_ws_text)
296300 }
297301
@@ -331,7 +335,7 @@ impl Article {
331335 ) ;
332336
333337 result. links . append ( & mut child_result. links ) ;
334- s. append ( child_result. s ) ;
338+ s. append ( child_result. content ) ;
335339 } ) ;
336340
337341 if !is_header {
0 commit comments