Skip to content
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

Batch: Fix escaped double quote #2485

Merged
merged 5 commits into from Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/prism-batch.js
Expand Up @@ -7,7 +7,7 @@
'punctuation': /:/
}
};
var string = /"[^"]*"/;
var string = /"(?:[\\"]"|[^"])*"/;
proudust marked this conversation as resolved.
Show resolved Hide resolved
var number = /(?:\b|-)\d+\b/;

Prism.languages.batch = {
Expand Down Expand Up @@ -76,7 +76,7 @@
},
{
// Other commands
pattern: /((?:^|[&(])[ \t]*@?)\w+\b(?:[^^&)\r\n]|\^(?:\r\n|[\s\S]))*/im,
pattern: /((?:^|[&(])[ \t]*@?)\w+\b(?:"(?:[\\"]"|[^"])*"|[^^&)\r\n]|\^(?:\r\n|[\s\S]))*/im,
proudust marked this conversation as resolved.
Show resolved Hide resolved
lookbehind: true,
inside: {
'keyword': /^\w+\b/i,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-batch.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions tests/languages/batch/string_feature.test
@@ -0,0 +1,29 @@
cmd ""
cmd "f\"oo"
cmd "f\\"oo"
cmd "print(""hello"")"

----------------------------------------------------

[
["command", [
["keyword", "cmd"],
["string", "\"\""]
]],
["command", [
["keyword", "cmd"],
["string", "\"f\\\"oo\""]
]],
["command", [
["keyword", "cmd"],
["string", "\"f\\\\\"oo\""]
]],
["command", [
["keyword", "cmd"],
["string", "\"print(\"\"hello\"\")\""]
]]
]

----------------------------------------------------

Checks for strings.