Преглед изворни кода

Merge pull request #14 from AndersMad/master

HTML Tags: Add support for dash and fix colon in end tag
Alexandru Dima пре 8 година
родитељ
комит
37e390f5ae
2 измењених фајлова са 17 додато и 3 уклоњено
  1. 3 3
      src/html.ts
  2. 14 0
      test/html.test.ts

+ 3 - 3
src/html.ts

@@ -76,11 +76,11 @@ export var language = <ILanguage> {
 		root: [
 			[/<!DOCTYPE/, 'metatag', '@doctype'],
 			[/<!--/, 'comment', '@comment'],
-			[/(<)(\w+)(\/>)/, [htmlTokenTypes.DELIM_START, 'tag', htmlTokenTypes.DELIM_END]],
+			[/(<)((?:[\w\-]+:)?[\w\-]+)(\s*)(\/>)/, [htmlTokenTypes.DELIM_START, 'tag', '', htmlTokenTypes.DELIM_END]],
 			[/(<)(script)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@script'} ]],
 			[/(<)(style)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@style'} ]],
-			[/(<)([:\w]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@otherTag'} ]],
-			[/(<\/)(\w+)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@otherTag' }]],
+			[/(<)((?:[\w\-]+:)?[\w\-]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@otherTag' }]],
+			[/(<\/)((?:[\w\-]+:)?[\w\-]+)/, [htmlTokenTypes.DELIM_START, { token: 'tag', next: '@otherTag' }]],
 			[/</, htmlTokenTypes.DELIM_START],
 			[/[^<]+/], // text
 		],

+ 14 - 0
test/html.test.ts

@@ -599,5 +599,19 @@ testTokenization(['html', 'css'], [
 			{ startIndex:0, type: DOCTYPE },
 			{ startIndex:11, type: DELIM_DOCTYPE }
 		]
+	}],
+
+	// PR #14
+	[{
+		line: '<asdf:bar>asd</asdf:bar>',
+		tokens: [
+			{ startIndex:0, type: DELIM_START },
+			{ startIndex:1, type: getTag('asdf:bar') },
+			{ startIndex:9, type: DELIM_END },
+			{ startIndex:10, type: '' },
+			{ startIndex:13, type: DELIM_START },
+			{ startIndex:15, type: getTag('asdf:bar') },
+			{ startIndex:23, type: DELIM_END }
+		]
 	}]
 ]);