Skip to content

Commit

Permalink
chore(audit) xml
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Nov 13, 2020
1 parent eeff8e5 commit 6c0840d
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/languages/xml.js
Expand Up @@ -2,6 +2,7 @@
Language: HTML, XML
Website: https://www.w3.org/XML/
Category: common
Audit: 2020
*/

import * as regex from '../lib/regex.js';
Expand All @@ -10,24 +11,24 @@ import * as regex from '../lib/regex.js';
export default function(hljs) {
// Element names can contain letters, digits, hyphens, underscores, and periods
const TAG_NAME_RE = regex.concat(/[A-Z_]/, regex.optional(/[A-Z0-9_.-]+:/), /[A-Z0-9_.-]*/);
const XML_IDENT_RE = '[A-Za-z0-9\\._:-]+';
const XML_IDENT_RE = /[A-Za-z0-9._:-]+/;
const XML_ENTITIES = {
className: 'symbol',
begin: '&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;'
begin: /&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/
};
const XML_META_KEYWORDS = {
begin: '\\s',
begin: /\s/,
contains: [
{
className: 'meta-keyword',
begin: '#?[a-z_][a-z1-9_-]+',
illegal: '\\n'
begin: /#?[a-z_][a-z1-9_-]+/,
illegal: /\n/
}
]
};
const XML_META_PAR_KEYWORDS = hljs.inherit(XML_META_KEYWORDS, {
begin: '\\(',
end: '\\)'
begin: /\(/,
end: /\)/
});
const APOS_META_STRING_MODE = hljs.inherit(hljs.APOS_STRING_MODE, {
className: 'meta-string'
Expand Down Expand Up @@ -90,22 +91,22 @@ export default function(hljs) {
contains: [
{
className: 'meta',
begin: '<![a-z]',
end: '>',
begin: /<![a-z]/,
end: />/,
relevance: 10,
contains: [
XML_META_KEYWORDS,
QUOTE_META_STRING_MODE,
APOS_META_STRING_MODE,
XML_META_PAR_KEYWORDS,
{
begin: '\\[',
end: '\\]',
begin: /\[/,
end: /\]/,
contains: [
{
className: 'meta',
begin: '<![a-z]',
end: '>',
begin: /<![a-z]/,
end: />/,
contains: [
XML_META_KEYWORDS,
XML_META_PAR_KEYWORDS,
Expand All @@ -118,15 +119,15 @@ export default function(hljs) {
]
},
hljs.COMMENT(
'<!--',
'-->',
/<!--/,
/-->/,
{
relevance: 10
}
),
{
begin: '<!\\[CDATA\\[',
end: '\\]\\]>',
begin: /<!\[CDATA\[/,
end: /\]\]>/,
relevance: 10
},
XML_ENTITIES,
Expand All @@ -144,14 +145,14 @@ export default function(hljs) {
ending braket. The '$' is needed for the lexeme to be recognized
by hljs.subMode() that tests lexemes outside the stream.
*/
begin: '<style(?=\\s|>)',
end: '>',
begin: /<style(?=\s|>)/,
end: />/,
keywords: {
name: 'style'
},
contains: [ TAG_INTERNALS ],
starts: {
end: '</style>',
end: /<\/style>/,
returnEnd: true,
subLanguage: [
'css',
Expand All @@ -162,8 +163,8 @@ export default function(hljs) {
{
className: 'tag',
// See the comment in the <style tag about the lookahead pattern
begin: '<script(?=\\s|>)',
end: '>',
begin: /<script(?=\s|>)/,
end: />/,
keywords: {
name: 'script'
},
Expand Down

0 comments on commit 6c0840d

Please sign in to comment.