Skip to content

Commit

Permalink
YAML parse non-word characters as part of tags highlightjs#2486
Browse files Browse the repository at this point in the history
  • Loading branch information
pplantinga committed Apr 9, 2020
1 parent ca23180 commit 062c81b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/languages/yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Category: common, config
export default function(hljs) {
var LITERALS = 'true false yes no null';

// YAML spec allows non-reserved characters in tags
var YAML_TAG_RE = '[a-zA-Z_.~@#$%():;+=-?/]\\w*'

// Define keys as starting with a word character
// ...containing word chars, spaces, colons, forward-slashes, hyphens and periods
// ...and ending with a colon followed immediately by a space, tab or newline.
Expand Down Expand Up @@ -72,11 +75,11 @@ export default function(hljs) {
},
{ // local tags
className: 'type',
begin: '!' + hljs.UNDERSCORE_IDENT_RE,
begin: '!' + YAML_TAG_RE,
},
{ // data type
className: 'type',
begin: '!!' + hljs.UNDERSCORE_IDENT_RE,
begin: '!!' + YAML_TAG_RE,
},
{ // fragment id &ref
className: 'meta',
Expand Down

0 comments on commit 062c81b

Please sign in to comment.