diff --git a/src/languages/yaml.js b/src/languages/yaml.js index fed5779490..44f5cb6da5 100644 --- a/src/languages/yaml.js +++ b/src/languages/yaml.js @@ -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. @@ -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',