From 20e6319fb9fa4ed3cf285b921a1f2e580c202a36 Mon Sep 17 00:00:00 2001 From: rickstrahl Date: Fri, 14 Aug 2020 15:39:34 -1000 Subject: [PATCH 1/3] Update italic highlighting rules to avoid intra word highlights. #4358 --- lib/ace/mode/markdown_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/markdown_highlight_rules.js b/lib/ace/mode/markdown_highlight_rules.js index d3a784f4c62..8186a160bea 100644 --- a/lib/ace/mode/markdown_highlight_rules.js +++ b/lib/ace/mode/markdown_highlight_rules.js @@ -148,7 +148,7 @@ var MarkdownHighlightRules = function() { regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)" }, { // emphasis * _ token : "string.emphasis", - regex : "([*]|[_](?=\\S))(.*?\\S[*_]*)(\\1)" + regex : "(?<=\\s|^)([*_])[^*_]*\\1(?=\\s|$)" }, { // token : ["text", "url", "text"], regex : "(<)("+ From 8944d628289a00095735e6bb9444b427c9ec412c Mon Sep 17 00:00:00 2001 From: rickstrahl Date: Fri, 14 Aug 2020 17:14:47 -1000 Subject: [PATCH 2/3] Fix IE RegEx with Italics parsing Check user agent and conditionally render italics with explict user agent check. --- lib/ace/mode/markdown_highlight_rules.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ace/mode/markdown_highlight_rules.js b/lib/ace/mode/markdown_highlight_rules.js index 8186a160bea..2278ddc18c3 100644 --- a/lib/ace/mode/markdown_highlight_rules.js +++ b/lib/ace/mode/markdown_highlight_rules.js @@ -35,6 +35,8 @@ var modes = require("../config").$modes; var oop = require("../lib/oop"); var lang = require("../lib/lang"); +var useragent = require("../lib/useragent"); + var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; @@ -121,7 +123,8 @@ var MarkdownHighlightRules = function() { }, { include : "basic" }); - + + this.addRules({ "basic" : [{ token : "constant.language.escape", @@ -147,8 +150,8 @@ var MarkdownHighlightRules = function() { token : "string.strong", regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)" }, { // emphasis * _ - token : "string.emphasis", - regex : "(?<=\\s|^)([*_])[^*_]*\\1(?=\\s|$)" + token : "string.emphasis", + regex : useragent.isIE ? "([*]|[_](?=\\S))(.*?\\S[*_]*)(\\1)" : "(?<=\\s|^)([*_])[^*_]*\\1(?=\\s|$)" }, { // token : ["text", "url", "text"], regex : "(<)("+ From c95021877f36ef50fc5ca1ca82a5b053c7c2a138 Mon Sep 17 00:00:00 2001 From: rickstrahl Date: Fri, 14 Aug 2020 21:14:49 -1000 Subject: [PATCH 3/3] Update IE Italic rendering in Markdown again. Use same RegEx as for otherbrowsers except the backreference in the RegEx. This isn't perfect, but will help prevent inline `_` highlighting if the underlines are not at the end followed by whitespace. This should address a large percentage of cases where this was a problem originally. --- lib/ace/mode/markdown_highlight_rules.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ace/mode/markdown_highlight_rules.js b/lib/ace/mode/markdown_highlight_rules.js index 2278ddc18c3..d532455df26 100644 --- a/lib/ace/mode/markdown_highlight_rules.js +++ b/lib/ace/mode/markdown_highlight_rules.js @@ -151,8 +151,8 @@ var MarkdownHighlightRules = function() { regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)" }, { // emphasis * _ token : "string.emphasis", - regex : useragent.isIE ? "([*]|[_](?=\\S))(.*?\\S[*_]*)(\\1)" : "(?<=\\s|^)([*_])[^*_]*\\1(?=\\s|$)" - }, { // + regex : useragent.isIE ? "([*_])[^*_]*\\1(?=\\s|$)" : "(?<=\\s|^)([*_])[^*_]*\\1(?=\\s|$)" + }, { // highlight urls token : ["text", "url", "text"], regex : "(<)("+ "(?:https?|ftp|dict):[^'\">\\s]+"+