Skip to content

Update the regex for matching single-quote and double-quote strings for PowerShell and Bash #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions shell/Markdown.VT/ColorCode.VT/Parser/Bash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ public class Bash : ILanguage
{1, BashCommentScope}
}),

new LanguageRule(
@"'[^\n]*?'",
new Dictionary<int, string>
{
{0, ScopeName.String}
}),

new LanguageRule(
@"""[^\n]*?(?<!\\)""",
new Dictionary<int, string>
{
{0, ScopeName.String}
}),

// match the first word of a line in a multi-line string as the command name.
new LanguageRule(
@"(?m)^\s*(\w+)",
Expand Down
4 changes: 2 additions & 2 deletions shell/Markdown.VT/ColorCode.VT/Parser/PowerShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public IList<LanguageRule> Rules
}),

new LanguageRule(
@"'[^\n]*?(?<!\\)'",
@"'[^\n]*?'",
new Dictionary<int, string>
{
{0, ScopeName.String}
Expand All @@ -62,7 +62,7 @@ public IList<LanguageRule> Rules
}),

new LanguageRule(
@"(?s)(""[^\n]*?(?<!`)"")",
@"""[^\n]*?(?<!`)""",
new Dictionary<int, string>
{
{0, ScopeName.String}
Expand Down