@@ -31,7 +31,7 @@ use std::rc::{Rc, Weak};
3131*/
3232use std:: {
3333 borrow:: Cow ,
34- cmp:: max,
34+ cmp:: { max, min } ,
3535 ffi:: OsStr ,
3636 iter:: Map ,
3737 ops:: Range ,
@@ -43,6 +43,7 @@ use std::{
4343use dprint_plugin_markdown:: {
4444 configuration:: {
4545 Configuration , ConfigurationBuilder , EmphasisKind , HeadingKind , StrongKind , TextWrap ,
46+ UnorderedListKind ,
4647 } ,
4748 format_text,
4849} ;
@@ -521,6 +522,7 @@ impl HtmlToMarkdownWrapped {
521522 word_wrap_config : ConfigurationBuilder :: new ( )
522523 . emphasis_kind ( EmphasisKind :: Asterisks )
523524 . strong_kind ( StrongKind :: Asterisks )
525+ . unordered_list_kind ( UnorderedListKind :: Asterisks )
524526 . text_wrap ( TextWrap :: Always )
525527 . heading_kind ( HeadingKind :: Setext )
526528 . build ( ) ,
@@ -531,7 +533,9 @@ impl HtmlToMarkdownWrapped {
531533 }
532534
533535 fn convert ( & self , html : & str ) -> std:: io:: Result < String > {
536+ println ! ( "Before:\n {html}" ) ;
534537 let converted = self . html_to_markdown . convert ( html) ?;
538+ println ! ( "Unwrapped:\n {converted}" ) ;
535539 Ok (
536540 format_text ( & converted, & self . word_wrap_config , |_, _, _| Ok ( None ) )
537541 . map_err ( std:: io:: Error :: other) ?
@@ -556,9 +560,11 @@ fn doc_block_html_to_markdown(
556560 // wrapping with large indents.
557561 converter. set_line_width ( max (
558562 WORD_WRAP_MIN_WIDTH ,
559- // The +1 factor is for the space separating the delimiter and the comment text.
563+ // The +1 factor is for the space separating the delimiter and
564+ // the comment text. Use `min` to avoid overflow with unsigned
565+ // subtraction.
560566 WORD_WRAP_COLUMN
561- - ( doc_block. delimiter . chars ( ) . count ( ) + 1 + doc_block. indent . chars ( ) . count ( ) ) ,
567+ - min ( doc_block. delimiter . chars ( ) . count ( ) + 1 + doc_block. indent . chars ( ) . count ( ) , WORD_WRAP_COLUMN ) ,
562568 ) ) ;
563569 doc_block. contents = converter
564570 . convert ( & doc_block. contents )
0 commit comments