@@ -10,12 +10,8 @@ Category: common, config
1010export default function ( hljs ) {
1111 var LITERALS = 'true false yes no null' ;
1212
13- // YAML spec allows non-reserved characters in tags, since they are intended
14- // to be used sometimes as URIs. In order to differentiate between "local"
15- // tags, prefixed with `!` and global tags, prefixed with `!!`, don't allow
16- // the prefix char `!` in the first char of the expression.
17- var NON_EXCLAMATION_CHARS = '\\w#;/?:@&=+$,.~*\\\'()[\\]'
18- var YAML_TAG_RE = '[' + NON_EXCLAMATION_CHARS + '][' + NON_EXCLAMATION_CHARS + '!]*'
13+ // YAML spec allows non-reserved URI characters in tags.
14+ var URI_CHARACTERS = '[\\w#;/?:@&=+$,.~*\\\'()[\\]]+'
1915
2016 // Define keys as starting with a word character
2117 // ...containing word chars, spaces, colons, forward-slashes, hyphens and periods
@@ -77,13 +73,17 @@ export default function(hljs) {
7773 excludeEnd : true ,
7874 relevance : 0
7975 } ,
76+ { // named tags
77+ className : 'type' ,
78+ begin : '!\\w+!' + URI_CHARACTERS ,
79+ } ,
8080 { // local tags
8181 className : 'type' ,
82- begin : '!' + YAML_TAG_RE ,
82+ begin : '!' + URI_CHARACTERS ,
8383 } ,
8484 { // data type
8585 className : 'type' ,
86- begin : '!!' + YAML_TAG_RE ,
86+ begin : '!!' + URI_CHARACTERS ,
8787 } ,
8888 { // fragment id &ref
8989 className : 'meta' ,
0 commit comments