Skip to content

Commit 481fbfb

Browse files
committed
Check for hard breaks more carefully to avoid false positives...
... caused by trailing tab characters. Fixes #250.
1 parent 64f3680 commit 481fbfb

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

src/md4c.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -4470,12 +4470,14 @@ md_process_inlines(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines)
44704470
MD_TEXTTYPE break_type = MD_TEXT_SOFTBR;
44714471

44724472
if(text_type == MD_TEXT_NORMAL) {
4473-
if(ctx->parser.flags & MD_FLAG_HARD_SOFT_BREAKS)
4474-
break_type = MD_TEXT_BR;
4475-
else if(enforce_hardbreak)
4476-
break_type = MD_TEXT_BR;
4477-
else if((CH(line->end) == _T(' ') && CH(line->end+1) == _T(' ')))
4473+
if(enforce_hardbreak || (ctx->parser.flags & MD_FLAG_HARD_SOFT_BREAKS)) {
44784474
break_type = MD_TEXT_BR;
4475+
} else {
4476+
while(off < ctx->size && ISBLANK(off))
4477+
off++;
4478+
if(off >= line->end + 2 && CH(off-2) == _T(' ') && CH(off-1) == _T(' ') && ISNEWLINE(off))
4479+
break_type = MD_TEXT_BR;
4480+
}
44794481
}
44804482

44814483
MD_TEXT(break_type, _T("\n"), 1);

test/regressions.txt

+24
Original file line numberDiff line numberDiff line change
@@ -761,3 +761,27 @@ baz*→
761761
<h1>Foo <em>bar
762762
baz</em></h1>
763763
````````````````````````````````
764+
765+
766+
## [Issue 250](https://github.com/mity/md4c/issues/250)
767+
768+
Handling trailing tabulator character versus hard break.
769+
770+
Space + space + tab + newline is not hard break:
771+
```````````````````````````````` example [no-normalize]
772+
foo →
773+
bar
774+
.
775+
<p>foo
776+
bar</p>
777+
````````````````````````````````
778+
779+
Tab + space + space + newline is hard break:
780+
```````````````````````````````` example [no-normalize]
781+
foo→
782+
bar
783+
.
784+
<p>foo<br>
785+
bar</p>
786+
````````````````````````````````
787+

0 commit comments

Comments
 (0)