File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 11[dependencies ]
22markdown = { path = " ../" , version = " 1.0.0" }
33regex = { version = " 1" }
4- unicode-width = { version = " 0.1" }
4+ unicode-width = { version = " 0.1" , optional = true }
5+
6+ [features ]
7+ default = []
8+ unicode-width = [" dep:unicode-width" ]
59
610[dev-dependencies ]
711pretty_assertions = { workspace = true }
Original file line number Diff line number Diff line change @@ -199,10 +199,18 @@ fn collect_text_content(nodes: &[Node], result: &mut String) {
199199 }
200200}
201201
202- /// Get the display width of a string, accounting for Unicode
202+ /// Get the display width of a string, accounting for Unicode when feature is enabled
203203fn display_width ( s : & str ) -> usize {
204- use unicode_width:: UnicodeWidthStr ;
205- UnicodeWidthStr :: width ( s)
204+ #[ cfg( feature = "unicode-width" ) ]
205+ {
206+ use unicode_width:: UnicodeWidthStr ;
207+ UnicodeWidthStr :: width ( s)
208+ }
209+ #[ cfg( not( feature = "unicode-width" ) ) ]
210+ {
211+ // Use character count instead of byte count for better default behavior
212+ s. chars ( ) . count ( )
213+ }
206214}
207215
208216/// Render the delimiter row with alignment markers
You can’t perform that action at this time.
0 commit comments