diff options
author | nyamatongwe <unknown> | 2011-08-26 08:57:10 +1000 |
---|---|---|
committer | nyamatongwe <unknown> | 2011-08-26 08:57:10 +1000 |
commit | d0443a3bd7c34e204b4e918a4184f0fb18f6cd79 (patch) | |
tree | 16ac8b10a7b4108c46897f345bb627258314a383 | |
parent | 88f9a63f05e08fed53c767cad7a72bb6d2f95e88 (diff) | |
download | scintilla-mirror-d0443a3bd7c34e204b4e918a4184f0fb18f6cd79.tar.gz |
Fixing Markdown lexer to not change state inside term. Bug #3398184.
From Eric Promislow at ActiveState.
-rw-r--r-- | lexers/LexMarkdown.cxx | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lexers/LexMarkdown.cxx b/lexers/LexMarkdown.cxx index 393712033..a92697707 100644 --- a/lexers/LexMarkdown.cxx +++ b/lexers/LexMarkdown.cxx @@ -113,6 +113,10 @@ static bool HasPrevLineContent(StyleContext &sc) { return false; } +static bool AtTermStart(StyleContext &sc) { + return sc.currentPos == 0 || isspacechar(sc.chPrev); +} + static bool IsValidHrule(const unsigned int endPos, StyleContext &sc) { int c, count = 1; unsigned int i = 0; @@ -373,35 +377,38 @@ static void ColorizeMarkdownDoc(unsigned int startPos, int length, int initStyle } } // Code - also a special case for alternate inside spacing - if (sc.Match("``") && sc.GetRelative(3) != ' ') { + if (sc.Match("``") && sc.GetRelative(3) != ' ' && AtTermStart(sc)) { sc.SetState(SCE_MARKDOWN_CODE2); sc.Forward(); } - else if (sc.ch == '`' && sc.chNext != ' ') { + else if (sc.ch == '`' && sc.chNext != ' ' && AtTermStart(sc)) { sc.SetState(SCE_MARKDOWN_CODE); } // Strong - else if (sc.Match("**") && sc.GetRelative(2) != ' ') { + else if (sc.Match("**") && sc.GetRelative(2) != ' ' && AtTermStart(sc)) { sc.SetState(SCE_MARKDOWN_STRONG1); sc.Forward(); } - else if (sc.Match("__") && sc.GetRelative(2) != ' ') { + else if (sc.Match("__") && sc.GetRelative(2) != ' ' && AtTermStart(sc)) { sc.SetState(SCE_MARKDOWN_STRONG2); sc.Forward(); } // Emphasis - else if (sc.ch == '*' && sc.chNext != ' ') + else if (sc.ch == '*' && sc.chNext != ' ' && AtTermStart(sc)) { sc.SetState(SCE_MARKDOWN_EM1); - else if (sc.ch == '_' && sc.chNext != ' ') + } + else if (sc.ch == '_' && sc.chNext != ' ' && AtTermStart(sc)) { sc.SetState(SCE_MARKDOWN_EM2); + } // Strikeout - else if (sc.Match("~~") && sc.GetRelative(2) != ' ') { + else if (sc.Match("~~") && sc.GetRelative(2) != ' ' && AtTermStart(sc)) { sc.SetState(SCE_MARKDOWN_STRIKEOUT); sc.Forward(); } // Beginning of line - else if (IsNewline(sc.ch)) + else if (IsNewline(sc.ch)) { sc.SetState(SCE_MARKDOWN_LINE_BEGIN); + } } // Advance if not holding back the cursor for this iteration. if (!freezeCursor) |