Fix escaping with surrounds - smu - smu - simple markup (Markdown) processor (f… | |
git clone git://git.codemadness.org/smu | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit b8bb25f4a7a08c5cecb21abab3835b25a079c7ec | |
parent 1df23c38824a74849c176a5a3bd54d9f1dba8817 | |
Author: Steven Dee <[email protected]> | |
Date: Sat, 22 Jun 2013 15:59:28 -0400 | |
Fix escaping with surrounds | |
When we assigned stop = strstr(start, search), we'd grab the first | |
match even if it was escaped. Instead, we update stop as we go. | |
Diffstat: | |
M smu.c | 6 ++++-- | |
M testdoc | 2 ++ | |
2 files changed, 6 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/smu.c b/smu.c | |
@@ -449,10 +449,12 @@ dosurround(const char *begin, const char *end, int newblo… | |
start = begin + l; | |
p = start - 1; | |
do { | |
+ stop = p; | |
p = strstr(p + 1, surround[i].search); | |
} while(p && p[-1] == '\\'); | |
- if(!p || p >= end || | |
- !(stop = strstr(start, surround[i].search)) ||… | |
+ if (p && p[-1] != '\\') | |
+ stop = p; | |
+ if(!stop || stop < start || stop >= end) | |
continue; | |
fputs(surround[i].before, stdout); | |
if(surround[i].process) | |
diff --git a/testdoc b/testdoc | |
@@ -7,6 +7,8 @@ simple tests | |
first paragraph. | |
testing surround: _emph_ then **strong** and `code`. | |
+`\`escaped backticks\``. | |
+ | |
`x = *y * 6;` | |
horizontal rule: |