From ef56187f733d946e4df130d9783eadea41ec1c97 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 7 Feb 2016 16:59:31 +0100 Subject: Fixed issue escaping ndashes (\--) and mdashes (\---) --- src/markdown.cpp | 27 +++++++++++---------------- testing/055/md_055_markdown.xml | 1 + testing/055_markdown.md | 2 ++ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/markdown.cpp b/src/markdown.cpp index 1723d1f..9bee243 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -1018,26 +1018,21 @@ static int processSpecialCommand(GrowBuf &out, const char *data, int offset, int if (size>1 && data[0]=='\\') { char c=data[1]; - if (c=='[' || c==']' || c=='*' || /* c=='+' || c=='-' || c=='.' || */ - c=='!' || c=='(' || c==')' || c=='`' || c=='_') + if (c=='[' || c==']' || c=='*' || c=='!' || c=='(' || c==')' || c=='`' || c=='_') { - if (c=='-' && size>3 && data[2]=='-' && data[3]=='-') // \--- - { - out.addStr(&data[1],3); - return 4; - } - else if (c=='-' && size>2 && data[2]=='-') // \-- - { - out.addStr(&data[1],2); - return 3; - } - else if (c=='-') // \- - { - out.addChar(c); - } out.addChar(data[1]); return 2; } + else if (c=='-' && size>3 && data[2]=='-' && data[3]=='-') // \--- + { + out.addStr(&data[1],3); + return 4; + } + else if (c=='-' && size>2 && data[2]=='-') // \-- + { + out.addStr(&data[1],2); + return 3; + } } return 0; } diff --git a/testing/055/md_055_markdown.xml b/testing/055/md_055_markdown.xml index 4006db8..18df45b 100644 --- a/testing/055/md_055_markdown.xml +++ b/testing/055/md_055_markdown.xml @@ -23,6 +23,7 @@ Upper-cased reference link on last line + Dash - NDash MDash EDash - ENDash -- EMDash --- E3Dash --- diff --git a/testing/055_markdown.md b/testing/055_markdown.md index aeb9f1a..375040e 100644 --- a/testing/055_markdown.md +++ b/testing/055_markdown.md @@ -20,3 +20,5 @@ More text [Upper-cased reference link on last line][U] [U]: http://example.com/last-line + +Dash - NDash -- MDash --- EDash \- ENDash \-- EMDash \--- E3Dash \-\-\- -- cgit v0.12