From badef2fcb37846eb319c42bad8fdb991b1a42222 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Fri, 7 Mar 2025 22:12:35 -0800 Subject: [PATCH] Update the regex for matching single-quote and double-quote strings for PowerShell and Bash --- shell/Markdown.VT/ColorCode.VT/Parser/Bash.cs | 14 ++++++++++++++ .../Markdown.VT/ColorCode.VT/Parser/PowerShell.cs | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/shell/Markdown.VT/ColorCode.VT/Parser/Bash.cs b/shell/Markdown.VT/ColorCode.VT/Parser/Bash.cs index d2719050..16cd9b19 100644 --- a/shell/Markdown.VT/ColorCode.VT/Parser/Bash.cs +++ b/shell/Markdown.VT/ColorCode.VT/Parser/Bash.cs @@ -24,6 +24,20 @@ public class Bash : ILanguage {1, BashCommentScope} }), + new LanguageRule( + @"'[^\n]*?'", + new Dictionary + { + {0, ScopeName.String} + }), + + new LanguageRule( + @"""[^\n]*?(? + { + {0, ScopeName.String} + }), + // match the first word of a line in a multi-line string as the command name. new LanguageRule( @"(?m)^\s*(\w+)", diff --git a/shell/Markdown.VT/ColorCode.VT/Parser/PowerShell.cs b/shell/Markdown.VT/ColorCode.VT/Parser/PowerShell.cs index c6f756ee..ff5ad5f4 100644 --- a/shell/Markdown.VT/ColorCode.VT/Parser/PowerShell.cs +++ b/shell/Markdown.VT/ColorCode.VT/Parser/PowerShell.cs @@ -48,7 +48,7 @@ public IList Rules }), new LanguageRule( - @"'[^\n]*?(? { {0, ScopeName.String} @@ -62,7 +62,7 @@ public IList Rules }), new LanguageRule( - @"(?s)(""[^\n]*?(? { {0, ScopeName.String}