aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexers/LexMarkdown.cxx
diff options
context:
space:
mode:
authornyamatongwe <unknown>2011-09-09 16:59:38 +1000
committernyamatongwe <unknown>2011-09-09 16:59:38 +1000
commitc4e2263b026a0b5aa67c421b767c3ebbabda654f (patch)
treea81b91816ba7a5b16ad676ba3a2776e99a3316af /lexers/LexMarkdown.cxx
parent9f1e13f587c8c3221a99cd2beee90242c32862fc (diff)
parent9b4a855ed7962ce5da8c3e538a38f3eb396a8cc7 (diff)
downloadscintilla-mirror-c4e2263b026a0b5aa67c421b767c3ebbabda654f.tar.gz
Merge with main repository.
Diffstat (limited to 'lexers/LexMarkdown.cxx')
-rw-r--r--lexers/LexMarkdown.cxx23
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)