Skip to content

Commit 3848bfb

Browse files
committed
Make striketrough spans follow same flanking rules...
... as other emphasis spans. Fixes #242.
1 parent 057915e commit 3848bfb

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Fixes:
1414
Fix quadratic time and output size behavior caused by malicious misuse of
1515
link reference definitions.
1616

17+
- [#242](https://github.com/mity/md4c/issues/242):
18+
The strike-through extension (with flag `MD_FLAG_STRIKETHROUGH`) now follows
19+
same logic as other emphasis spans in respect to punctuation character and
20+
word boundaries.
21+
1722

1823
## Version 0.5.2
1924

src/md4c.c

+3-27
Original file line numberDiff line numberDiff line change
@@ -3295,35 +3295,11 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, int table_m
32953295
continue;
32963296
}
32973297

3298-
/* A potential strikethrough start/end. */
3299-
if(ch == _T('~')) {
3298+
/* A potential strikethrough/equation start/end. */
3299+
if(ch == _T('$') || ch == _T('~')) {
33003300
OFF tmp = off+1;
33013301

3302-
while(tmp < line->end && CH(tmp) == _T('~'))
3303-
tmp++;
3304-
3305-
if(tmp - off < 3) {
3306-
unsigned flags = 0;
3307-
3308-
if(tmp < line->end && !ISUNICODEWHITESPACE(tmp))
3309-
flags |= MD_MARK_POTENTIAL_OPENER;
3310-
if(off > line->beg && !ISUNICODEWHITESPACEBEFORE(off))
3311-
flags |= MD_MARK_POTENTIAL_CLOSER;
3312-
if(flags != 0)
3313-
ADD_MARK(ch, off, tmp, flags);
3314-
}
3315-
3316-
off = tmp;
3317-
continue;
3318-
}
3319-
3320-
/* A potential equation start/end */
3321-
if(ch == _T('$')) {
3322-
/* We can have at most two consecutive $ signs,
3323-
* where two dollar signs signify a display equation. */
3324-
OFF tmp = off+1;
3325-
3326-
while(tmp < line->end && CH(tmp) == _T('$'))
3302+
while(tmp < line->end && CH(tmp) == ch)
33273303
tmp++;
33283304

33293305
if(tmp - off <= 2) {

test/regressions.txt

+14
Original file line numberDiff line numberDiff line change
@@ -726,3 +726,17 @@ https://example.com/dir/
726726
.
727727
--fpermissive-url-autolinks
728728
````````````````````````````````
729+
730+
731+
## [Issue 242](https://github.com/mity/md4c/issues/242)
732+
733+
```````````````````````````````` example
734+
copy ~user1/file to ~user2/file
735+
736+
copy "~user1/file" to "~user2/file"
737+
.
738+
<p>copy ~user1/file to ~user2/file</p>
739+
<p>copy &quot;~user1/file&quot; to &quot;~user2/file&quot;</p>
740+
.
741+
--fstrikethrough
742+
````````````````````````````````

0 commit comments

Comments
 (0)