Skip to content

Commit

Permalink
Fix PrismJS#1601 Allow strings to have trailing comments
Browse files Browse the repository at this point in the history
Updates the string regex to allow for strings that may have a trailing '#'.
This uses a different pattern from other regex patterns, because only
the string regex pattern is greedy, while the others are not.
  • Loading branch information
Chris-Johnston committed Oct 29, 2018
1 parent da474c7 commit 7411027
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion components/prism-yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Prism.languages.yaml = {
alias: 'important'
},
'string': {
pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)("|')(?:(?!\2)[^\\\r\n]|\\.)*\2(?=[ \t]*(?:$|,|]|}))/m,
pattern: /([:\-,[{]\s*(?:![^\s]+)?[ \t]*)("|')(?:(?!\2)[^\\\r\n]|\\.)*\2(?=[ \t]*(?:$|,|]|}|(\s*#)))/m,
lookbehind: true,
greedy: true
},
Expand Down

0 comments on commit 7411027

Please sign in to comment.