Skip to content

Commit ca8eaee

Browse files
Markup: Fixed quotes in HTML attribute values (#3442)
1 parent 0d4b6cb commit ca8eaee

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

components/prism-markup.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ Prism.languages.markup = {
5151
pattern: /^=/,
5252
alias: 'attr-equals'
5353
},
54-
/"|'/
54+
{
55+
pattern: /^(\s*)["']|["']$/,
56+
lookbehind: true
57+
}
5558
]
5659
}
5760
},

components/prism-markup.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prism.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,10 @@ Prism.languages.markup = {
13251325
pattern: /^=/,
13261326
alias: 'attr-equals'
13271327
},
1328-
/"|'/
1328+
{
1329+
pattern: /^(\s*)["']|["']$/,
1330+
lookbehind: true
1331+
}
13291332
]
13301333
}
13311334
},

tests/languages/markup!+javascript/javascript_inclusion.test

+1-4
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,7 @@ let foo = '</script>';
143143
["attr-value", [
144144
["punctuation", "="],
145145
["punctuation", "\""],
146-
"this.textContent=",
147-
["punctuation", "'"],
148-
"Over!",
149-
["punctuation", "'"],
146+
"this.textContent='Over!'",
150147
["punctuation", "\""]
151148
]],
152149
["punctuation", ">"]

tests/languages/markup/issue3441.test

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<google-chart data='[["Month", "Days"], ["Jan", 31]]'></google-chart>
2+
3+
----------------------------------------------------
4+
5+
[
6+
["tag", [
7+
["tag", [
8+
["punctuation", "<"],
9+
"google-chart"
10+
]],
11+
["attr-name", ["data"]],
12+
["attr-value", [
13+
["punctuation", "="],
14+
["punctuation", "'"],
15+
"[[\"Month\", \"Days\"], [\"Jan\", 31]]",
16+
["punctuation", "'"]
17+
]],
18+
["punctuation", ">"]
19+
]],
20+
["tag", [
21+
["tag", [
22+
["punctuation", "</"],
23+
"google-chart"
24+
]],
25+
["punctuation", ">"]
26+
]]
27+
]

0 commit comments

Comments
 (0)