Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make striketrough spans follow same flanking rules... #243

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Fixes:
Fix quadratic time and output size behavior caused by malicious misuse of
link reference definitions.

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


## Version 0.5.2

Expand Down
30 changes: 3 additions & 27 deletions src/md4c.c
Original file line number Diff line number Diff line change
Expand Up @@ -3295,35 +3295,11 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, MD_SIZE n_lines, int table_m
continue;
}

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

while(tmp < line->end && CH(tmp) == _T('~'))
tmp++;

if(tmp - off < 3) {
unsigned flags = 0;

if(tmp < line->end && !ISUNICODEWHITESPACE(tmp))
flags |= MD_MARK_POTENTIAL_OPENER;
if(off > line->beg && !ISUNICODEWHITESPACEBEFORE(off))
flags |= MD_MARK_POTENTIAL_CLOSER;
if(flags != 0)
ADD_MARK(ch, off, tmp, flags);
}

off = tmp;
continue;
}

/* A potential equation start/end */
if(ch == _T('$')) {
/* We can have at most two consecutive $ signs,
* where two dollar signs signify a display equation. */
OFF tmp = off+1;

while(tmp < line->end && CH(tmp) == _T('$'))
while(tmp < line->end && CH(tmp) == ch)
tmp++;

if(tmp - off <= 2) {
Expand Down
14 changes: 14 additions & 0 deletions test/regressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -726,3 +726,17 @@ https://example.com/dir/
.
--fpermissive-url-autolinks
````````````````````````````````


## [Issue 242](https://github.com/mity/md4c/issues/242)

```````````````````````````````` example
copy ~user1/file to ~user2/file

copy "~user1/file" to "~user2/file"
.
<p>copy ~user1/file to ~user2/file</p>
<p>copy &quot;~user1/file&quot; to &quot;~user2/file&quot;</p>
.
--fstrikethrough
````````````````````````````````
Loading