Make striketrough spans follow same flanking rules... ... as other emphasis spans. Fixes #242.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0114eb8..e02071b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/src/md4c.c b/src/md4c.c
index a56204e..054c559 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -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) {
diff --git a/test/regressions.txt b/test/regressions.txt
index 284a532..7411206 100644
--- a/test/regressions.txt
+++ b/test/regressions.txt
@@ -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 "~user1/file" to "~user2/file"</p>
+.
+--fstrikethrough
+````````````````````````````````