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 authored and joshgoebel committed Apr 21, 2020
1 parent 2d90a5c commit 017f978
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/languages/yaml.js
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 @@ -81,11 +84,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 017f978

Please sign in to comment.