File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -231,9 +231,11 @@ impl<'a> PageRenderer<'a> {
231
231
for w in words {
232
232
let mut w_width = w. width ( ) ;
233
233
let backtick_count = w. chars ( ) . filter ( |x| * x == '`' ) . count ( ) ;
234
+ // Backticks won't be displayed.
234
235
w_width -= backtick_count;
235
236
236
- if cur_width + w_width > max_len && cur_width != base_width {
237
+ // current + word + space after the word
238
+ if cur_width + w_width + 1 > max_len && cur_width != base_width {
237
239
// If the next word is added, the line will be longer than the configured line
238
240
// length.
239
241
//
@@ -263,6 +265,9 @@ impl<'a> PageRenderer<'a> {
263
265
buf += w;
264
266
cur_width += w_width;
265
267
268
+ // If there are two backticks in `w`, then `w` contains all the highlighted text.
269
+ // If there is only one (e.g `ab cd` => split into words ["`ab", "cd`"]), it
270
+ // starts/ends the highlight.
266
271
if backtick_count == 1 {
267
272
inside_hl = !inside_hl;
268
273
}
You can’t perform that action at this time.
0 commit comments