From a4921fe7ceb3c484804ab287d75b9f77cf8a13f7 Mon Sep 17 00:00:00 2001 From: Garen Torikian Date: Mon, 30 Sep 2013 15:41:21 -0700 Subject: [PATCH] Fix GFM blocks within lists --- lib/ace/mode/markdown_highlight_rules.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/ace/mode/markdown_highlight_rules.js b/lib/ace/mode/markdown_highlight_rules.js index a7e5a105..db4caec8 100644 --- a/lib/ace/mode/markdown_highlight_rules.js +++ b/lib/ace/mode/markdown_highlight_rules.js @@ -46,7 +46,7 @@ var escaped = function(ch) { function github_embed(tag, prefix) { return { // Github style block token : "support.function", - regex : "^```" + tag + "\\s*$", + regex : "^\\s*```" + tag + "\\s*$", push : prefix + "start" }; } @@ -79,7 +79,7 @@ var MarkdownHighlightRules = function() { github_embed("css", "csscode-"), { // Github style block token : "support.function", - regex : "^```\\s*\\S*(?:{.*?\\})?\\s*$", + regex : "^\\s*```\\s*\\S*(?:{.*?\\})?\\s*$", next : "githubblock" }, { // block quote token : "string.blockquote", @@ -164,11 +164,15 @@ var MarkdownHighlightRules = function() { next : "listblock-start" }, { include : "basic", noEscape: true + }, { // Github style block + token : "support.function", + regex : "^\\s*```\\s*[a-zA-Z]*(?:{.*?\\})?\\s*$", + next : "githubblock" }, { defaultToken : "list" //do not use markup.list to allow stling leading `*` differntly } ], - "blockquote" : [ { // BLockquotes only escape on blank lines. + "blockquote" : [ { // Blockquotes only escape on blank lines. token : "empty_line", regex : "^\\s*$", next : "start" @@ -184,7 +188,7 @@ var MarkdownHighlightRules = function() { "githubblock" : [ { token : "support.function", - regex : "^```", + regex : "^\\s*```", next : "start" }, { token : "support.function", @@ -194,25 +198,25 @@ var MarkdownHighlightRules = function() { this.embedRules(JavaScriptHighlightRules, "jscode-", [{ token : "support.function", - regex : "^```", + regex : "^\\s*```", next : "pop" }]); this.embedRules(HtmlHighlightRules, "htmlcode-", [{ token : "support.function", - regex : "^```", + regex : "^\\s*```", next : "pop" }]); this.embedRules(CssHighlightRules, "csscode-", [{ token : "support.function", - regex : "^```", + regex : "^\\s*```", next : "pop" }]); this.embedRules(XmlHighlightRules, "xmlcode-", [{ token : "support.function", - regex : "^```", + regex : "^\\s*```", next : "pop" }]);