Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #6 from SpotterRF/modularize

Can now load select languages (rather than all)
  • Loading branch information...
commit edccb418f17a0c719179d3fbcdfa735f231a9cd8 2 parents 907a91c + acd89c1
@andris9 authored
View
113 bin/highlight-cli.js
@@ -0,0 +1,113 @@
+#!/usr/bin/env node
+(function () {
+ "use strict";
+
+ var fs = require('fs')
+ , Highlight = require('highlight')
+ //, Highlight = require('../lib/highlight')
+ , filename = process.argv[2]
+ , langArgIndex = 4
+ , langArg
+ , langs
+ ;
+
+ if (filename.match(/--languages(=)?/)) {
+ langArg = filename;
+ langArgIndex = 3;
+ filename = null;
+ }
+
+ langArg = process.argv[langArgIndex - 1] || '';
+
+ if (langArg = langArg.match(/--languages(=(.*))?/)) {
+ langs = (process.argv[langArgIndex]||'').split(/\s*,\s*/g);
+
+ if (langArg[2]) {
+ langs = langArg[2].split(/,/);
+ }
+ }
+
+ function printUsage() {
+ console.warn("Usages:");
+ console.warn("highlight site/docs/index.html > highlighted.html");
+ console.warn("cat site/docs/index.html | highlight > highlighted.html");
+ }
+
+ function handleInput(err, text) {
+ var hlBlock
+ , wrappedInHtml
+ ;
+
+ if (err) {
+ printUsage();
+ return;
+ }
+
+ wrappedInHtml = !!text.match(/<.*?code.*?>/i);
+
+ // TODO test if filename extension reveals code type
+ Highlight.init(function (err) {
+ if (err) {
+ console.error('[highlight-cli]', err.message);
+ //console.error(err.stack);
+ return;
+ }
+
+ hlBlock = Highlight.highlight(text, ' ', wrappedInHtml);
+ console.info(hlBlock);
+ }, langs);
+ }
+
+ readInput(handleInput, filename);
+
+ //
+ // this could (and probably should) be its own module
+ //
+ function readInput(cb, filename) {
+
+ function readFile() {
+ fs.readFile(filename, 'utf8', function (err, text) {
+ if (err) {
+ console.error("[ERROR] couldn't read from '" + filename + "':");
+ console.error(err.message);
+ return;
+ }
+
+ cb(err, text);
+ });
+ }
+
+ function readStdin() {
+ var text = ''
+ , timeoutToken
+ , stdin = process.stdin
+ ;
+
+ stdin.resume();
+
+ // how to tell piping vs waiting for user input?
+ timeoutToken = setTimeout(function () {
+ cb(new Error('no stdin data'));
+ stdin.pause();
+ }, 1000);
+
+ stdin.on('data', function (chunk) {
+ clearTimeout(timeoutToken);
+ text += chunk;
+ });
+
+ stdin.on('end', function () {
+ cb(null, text);
+ });
+ }
+
+ if (filename) {
+ readFile();
+ }
+ else {
+ readStdin();
+ }
+
+ }
+
+}());
View
34 bin/package.json
@@ -0,0 +1,34 @@
+{
+ "name" : "highlight-cli",
+ "description" : "cli for the highlight module",
+ "version" : "1.1.0",
+ "author" : "AJ ONeal",
+ "homepage": "https://github.com/andris9/highlight",
+ "maintainers":[
+ {
+ "name":"andris",
+ "email":"andris@node.ee"
+ }
+ ],
+ "engines": {
+ "node": "*"
+ },
+ "repository" : {
+ "type" : "git",
+ "url" : "http://github.com/andris9/highlight.git"
+ },
+ "bin": {
+ "highlight": "./highlight-cli.js"
+ },
+ "main": "./highlight-cli",
+ "dependencies": {
+ "highlight": "*"
+ },
+ "licenses" : [
+ {
+ "type": "BSD",
+ "url": "http://github.com/andris9/highlight/blob/master/LICENSE"
+ }
+ ],
+ "preferGlobal": true
+}
View
16 examples/example.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Foo</title>
+ </head>
+ <body>
+ Bar
+ <br/>
+ Baz
+ <p>Quux</p>
+ <ul>
+ <li>Qux</li>
+ <li>Grault</li>
+ </ul>
+ </body>
+</html>
View
5 examples/example.js
@@ -0,0 +1,5 @@
+(function () {
+ "use strict";
+
+ console.log('Hello World!');
+}();
View
5 examples/example.js.html
@@ -0,0 +1,5 @@
+<pre><code>(function () {
+ "use strict";
+
+ console.log('Hello World!');
+}();</code></pre>
View
29 examples/should-annotate-xml.js
@@ -0,0 +1,29 @@
+(function () {
+ "use strict";
+
+ var Highlight = require("../lib/highlight.js")
+ , assert = require('assert')
+ , fs = require('fs')
+ , reHasAnnotations = /\sclass="tag"/
+ ;
+
+ function runTest(err) {
+
+ assert.ok(!err, err && err.message);
+ assert.strictEqual(1, Highlight.loadedLanguages.length, 'more than one language is loaded: ' + Highlight.loadedLanguages);
+ assert.strictEqual('xml', Highlight.loadedLanguages[0], 'xml isn\'t the language');
+
+ fs.readFile('./example.html', 'utf8', function (err, text) {
+ var annotated
+ ;
+
+ assert.ok(!err, 'threw error reading example.html');
+ annotated = Highlight.highlight(text, ' ');
+ assert.ok(annotated.match(reHasAnnotations));
+ //console.log(annotated);
+ console.info('[PASS] source is annotated');
+ });
+ }
+
+ Highlight.init(runTest, ['xml']);
+}());
View
41 examples/should-load-all-languages.js
@@ -0,0 +1,41 @@
+(function () {
+ "use strict";
+
+ var Highlight = require("../lib/highlight.js")
+ , assert = require('assert')
+ , fs = require('fs')
+ , reHasAnnotations = /\sclass="[\w-]+"/
+ ;
+
+ function runTest(err) {
+
+ //console.log(Highlight.loadedLanguages);
+ assert.ok(!err, err && err.message);
+ assert.strictEqual(Highlight.languages.length, Highlight.loadedLanguages.length
+ , 'not all languages were loaded: '
+ + Highlight.languages.length
+ + " "
+ + Highlight.loadedLanguages.length
+ );
+ assert.deepEqual(Highlight.languages, Highlight.loadedLanguages
+ , 'not all languages were loaded: '
+ + JSON.stringify(Highlight.languages, null, ' ')
+ + "\n"
+ + JSON.stringify(Highlight.loadedLanguages, null, ' ')
+ );
+
+ // It's okay that these run out-of-order / in-parallel
+ fs.readFile('./example.js', 'utf8', function (err, text) {
+ var annotated
+ ;
+
+ assert.ok(!err, 'threw error reading example.js');
+ annotated = Highlight.highlight(text, ' ');
+ assert.ok(annotated.match(reHasAnnotations));
+ //console.log(annotated);
+ console.info('[PASS] annotated source (perhaps incorrectly) with all modules loaded');
+ });
+ }
+
+ Highlight.init(runTest);
+}());
View
29 examples/should-load-js-only.js
@@ -0,0 +1,29 @@
+(function () {
+ "use strict";
+
+ var Highlight = require("../lib/highlight.js")
+ , assert = require('assert')
+ , fs = require('fs')
+ , reHasAnnotations = /\sclass="[\w-]+"/
+ ;
+
+ function runTest(err) {
+
+ assert.ok(!err, err && err.message);
+ assert.strictEqual(1, Highlight.loadedLanguages.length, 'more than one language is loaded: ' + Highlight.loadedLanguages);
+ assert.strictEqual('javascript', Highlight.loadedLanguages[0], 'javascript is the language');
+
+ fs.readFile('./example.js.html', 'utf8', function (err, text) {
+ var annotated
+ ;
+
+ assert.ok(!err, 'threw error reading example.js.html');
+ annotated = Highlight.highlight(text, ' ', true);
+ assert.ok(annotated.match(reHasAnnotations));
+ //console.log(annotated);
+ console.info('[PASS] source is annotated');
+ });
+ }
+
+ Highlight.init(runTest, ['javascript']);
+}());
View
36 examples/should-load-no-languages.js
@@ -0,0 +1,36 @@
+(function () {
+ "use strict";
+
+ var Highlight = require("../lib/highlight.js")
+ , assert = require('assert')
+ , fs = require('fs')
+ , reHasMarkup = /<.*class=["']?[\w-]+["'?]/
+ , reHasAnnotations = /\sclass="[\w-]+"/
+ ;
+
+ function runTest(err) {
+
+ //console.log(Highlight.loadedLanguages);
+ assert.ok(!err, err && err.message);
+ assert.strictEqual(0, Highlight.loadedLanguages.length
+ , 'some languages were loaded: '
+ + Highlight.languages.length
+ + " "
+ + Highlight.loadedLanguages.length
+ );
+
+ // It's okay that these run out-of-order / in-parallel
+ fs.readFile('./example.js', 'utf8', function (err, text) {
+ var annotated
+ ;
+
+ assert.ok(!err, 'threw error reading example.js');
+ annotated = Highlight.highlight(text, ' ');
+ assert.ok(!annotated.match(reHasAnnotations));
+ //console.log(annotated);
+ console.info('[PASS] source is not annotated');
+ });
+ }
+
+ Highlight.init(runTest, []);
+}());
View
245 lib/highlight.js
@@ -1,70 +1,177 @@
-/* node-highlight is based on highlight.js (see vendor/highlight.js) */
-/* usage: html = require("highlight").Highlight(code_string); */
-/* NB! You also need to include a CSS file from vendor/highlight.js/styles */
-
-// load syntax highlighter
-var hljs = require("./vendor/highlight.js/highlight").hljs;
-
-// load langs
-require("./vendor/highlight.js/languages/xml")(hljs);
-require("./vendor/highlight.js/languages/1c")(hljs);
-require("./vendor/highlight.js/languages/apache")(hljs);
-require("./vendor/highlight.js/languages/avrasm")(hljs);
-require("./vendor/highlight.js/languages/axapta")(hljs);
-require("./vendor/highlight.js/languages/bash")(hljs);
-require("./vendor/highlight.js/languages/cmake")(hljs);
-require("./vendor/highlight.js/languages/cpp")(hljs);
-require("./vendor/highlight.js/languages/cs")(hljs);
-require("./vendor/highlight.js/languages/css")(hljs);
-require("./vendor/highlight.js/languages/delphi")(hljs);
-require("./vendor/highlight.js/languages/diff")(hljs);
-require("./vendor/highlight.js/languages/django")(hljs);
-require("./vendor/highlight.js/languages/dos")(hljs);
-require("./vendor/highlight.js/languages/erlang-repl")(hljs);
-require("./vendor/highlight.js/languages/erlang")(hljs);
-require("./vendor/highlight.js/languages/go")(hljs);
-require("./vendor/highlight.js/languages/haskell")(hljs);
-require("./vendor/highlight.js/languages/ini")(hljs);
-require("./vendor/highlight.js/languages/java")(hljs);
-require("./vendor/highlight.js/languages/javascript")(hljs);
-require("./vendor/highlight.js/languages/lisp")(hljs);
-require("./vendor/highlight.js/languages/lua")(hljs);
-require("./vendor/highlight.js/languages/mel")(hljs);
-require("./vendor/highlight.js/languages/nginx")(hljs);
-require("./vendor/highlight.js/languages/objectivec")(hljs);
-require("./vendor/highlight.js/languages/parser3")(hljs);
-require("./vendor/highlight.js/languages/perl")(hljs);
-require("./vendor/highlight.js/languages/php")(hljs);
-require("./vendor/highlight.js/languages/profile")(hljs);
-require("./vendor/highlight.js/languages/python")(hljs);
-require("./vendor/highlight.js/languages/renderman")(hljs);
-require("./vendor/highlight.js/languages/ruby")(hljs);
-require("./vendor/highlight.js/languages/scala")(hljs);
-require("./vendor/highlight.js/languages/smalltalk")(hljs);
-require("./vendor/highlight.js/languages/sql")(hljs);
-require("./vendor/highlight.js/languages/tex")(hljs);
-require("./vendor/highlight.js/languages/vala")(hljs);
-require("./vendor/highlight.js/languages/vbscript")(hljs);
-require("./vendor/highlight.js/languages/vhdl")(hljs);
-
-
-
-/**
- * highlight(text, tabReplace, useCodeBlocks) -> HTML
- * - text (String): text to be highlighted
- * - tabReplace (String): defaults to 4 spaces if none, replaces \t chars
- * - useCodeBlocks (Boolean): If TRUE use only text between <code> and </code>
- *
- * Highlights program code inside a string by setting appropriate CSS class
- * elements.
- **/
-this.Highlight = function(text, tabReplace, useCodeBlocks){
+// TODO why is `this` in use at all?
+var self = this;
+
+(function () {
+ "use strict";
+ /* node-highlight is based on highlight.js (see vendor/highlight.js) */
+ /* usage: html = require("highlight").Highlight(code_string); */
+ /* NB! You also need to include a CSS file from vendor/highlight.js/styles */
+
+ // load syntax highlighter
+ // TODO create private instances of highlighter
+ // (with fewer langs) for greater accuracy
+ var Highlight = module.exports
+ , fs = require('fs')
+ , hljs = require('./vendor/highlight.js/highlight').hljs
+ , langRelPath = "vendor/highlight.js/languages/"
+ , langPath = __dirname + "/" + langRelPath
+ , reEndsWithJs = /\.js$/i
+ , loadedMap = {}
+ , availableMap = {}
+ ;
+
+ // TODO this should move to init in a newer api
+ Highlight.loadedLanguages = [];
+
+ function acceptJsFiles(lang) {
+ if (lang.match(reEndsWithJs)) {
+ return true;
+ }
+ }
+
+ function preRequireModules(lang, i, arr) {
+ arr[i] = lang = lang.replace(reEndsWithJs, '');
+
+ try {
+ availableMap[lang] = require('./' + langRelPath + lang);
+ } catch(e) {
+ console.error("[ERROR] could not preload language pack for '" + lang + "'");
+ console.error(e.message);
+ console.error(e.stack);
+ return;
+ }
+ }
+
+ // find languages from list of fsnodes
+ function preloadLanguages(err, fsnodes) {
+
+ if (err) {
+ console.error("[ERROR] langPath '" + langPath + "'");
+ console.error(err.message);
+ console.error(err.stack);
+ return;
+ }
+
+ Highlight.languages = fsnodes.filter(acceptJsFiles).sort(function (a, b) {
+ // xml must be first (others depend on it)
+ if ('xml' === a) {
+ return -100000000;
+ }
+ // django should be after xml
+ if ('django.js' === a) {
+ return 1000000000;
+ }
+
+ if (a === b) {
+ return 0;
+ }
+
+ if (a < b) {
+ return -1;
+ } else if (a > b) {
+ return 1;
+ } else {
+ // NaN vs string
+ return 0;
+ }
+ });
+ Highlight.languages.forEach(preRequireModules);
+ }
+
+ function loadLangs(cb, langs) {
+ var err
+ ;
+
+ if ('string' === typeof langs) {
+ langs = [langs];
+ }
+
+ if (!Array.isArray(langs)) {
+ cb(new Error("no array of languages given"));
+ return;
+ }
+
+ langs.some(function (lang) {
+ var addLangToHighlightInstance
+ ;
+
+ if (loadedMap[lang]) {
+ return;
+ }
+
+ addLangToHighlightInstance = availableMap[lang];
+
+ if (!addLangToHighlightInstance) {
+ err = new Error("No language pack available for '" + lang + "'");
+ return true;
+ }
+
+ try {
+ addLangToHighlightInstance(hljs);
+ } catch(e) {
+ // TODO fix django and html-xml
+ console.warn('[WARN] failed to load', lang);
+ console.warn(e.message);
+ console.warn(e.stack);
+ Highlight.languages = Highlight.languages.filter(function (l) {
+ return l !== lang;
+ });
+ return;
+ }
+
+ loadedMap[lang] = true;
+ Highlight.loadedLanguages.push(lang);
+ });
+
+ // future-proofing for async api
+ cb(err);
+ }
+
+ function init(cb, langs, opts) {
+ if (!Array.isArray(langs)) {
+ langs = Highlight.languages.slice();
+ }
+
+ loadLangs(cb, langs);
+ }
+
+ /**
+ * highlight(text, tabReplace, useCodeBlocks) -> HTML
+ * - text (String): text to be highlighted
+ * - tabReplace (String): defaults to 4 spaces if none, replaces \t chars
+ * - useCodeBlocks (Boolean): If TRUE use only text between <code> and </code>
+ *
+ * Highlights program code inside a string by setting appropriate CSS class
+ * elements.
+ **/
+ function highlight(text, tabReplace, useCodeBlocks){
tabReplace = tabReplace || ' ';
- if(!!useCodeBlocks){
- // JS regexpes have some multiline issues, so we temporarily remove them
- return text.replace(/\n/g,'\uffff').replace(/<code>(.*?)<\/code>/gm, function(original, source){
- return '<code>'+hljs.highlightText(source.replace(/\uffff/g,"\n"), tabReplace)+'</code>';
- }).replace(/&amp;(\w+;)/g,'&$1').replace(/\uffff/g,"\n");
- }else
- return hljs.highlightText(text, tabReplace);
-}
+ if (!!useCodeBlocks) {
+ // JS regexpes have some multiline issues, so we temporarily remove them
+ return text
+ .replace(/\n/g,'\uffff')
+ .replace(/<code>(.*?)<\/code>/gm, function(original, source){
+ return '<code>'+hljs.highlightText(source.replace(/\uffff/g,"\n"), tabReplace)+'</code>';
+ })
+ .replace(/&amp;(\w+;)/g,'&$1').replace(/\uffff/g,"\n");
+ } else {
+ return hljs.highlightText(text, tabReplace);
+ }
+ }
+
+ //fs.readdir(langPath, preloadLanguages);
+ // using readdirSync To avoid API Change
+ preloadLanguages(null, fs.readdirSync(langPath));
+
+ Highlight.init = init;
+ Highlight.highlight = highlight;
+
+ // Maintain current api:
+ // TODO why is `this` in use at all?
+ function backwardsCompat() {
+ // currently synchronous
+ Highlight.init(function () {}, ['php']);
+ return Highlight.highlight.apply(null, arguments);
+ }
+ Highlight.Highlight = self.Highlight = backwardsCompat;
+}());
View
143 lib/vendor/highlight.js/languages/html-xml.js
@@ -1,143 +0,0 @@
-/*
-Language: HTML, XML
-*/
-
-this.lang = function(hljs){
-
-hljs.XML_COMMENT = {
- className: 'comment',
- begin: '<!--', end: '-->'
-};
-hljs.XML_ATTR = {
- className: 'attribute',
- begin: '\\s[A-Za-z0-9\\._:-]+=', end: '^',
- contains: ['value']
-};
-hljs.XML_VALUE_QUOT = {
- className: 'value',
- begin: '"', end: '"'
-};
-hljs.XML_VALUE_APOS = {
- className: 'value',
- begin: '\'', end: '\''
-};
-
-
-hljs.LANGUAGES.xml = {
- defaultMode: {
- contains: ['pi', 'comment', 'cdata', 'tag']
- },
- case_insensitive: true,
- modes: [
- {
- className: 'pi',
- begin: '<\\?', end: '\\?>',
- relevance: 10
- },
- hljs.XML_COMMENT,
- {
- className: 'cdata',
- begin: '<\\!\\[CDATA\\[', end: '\\]\\]>'
- },
- {
- className: 'tag',
- begin: '</?', end: '>',
- contains: ['title', 'tag_internal'],
- relevance: 1.5
- },
- {
- className: 'title',
- begin: '[A-Za-z0-9\\._:-]+', end: '^',
- relevance: 0
- },
- {
- className: 'tag_internal',
- begin: '^', endsWithParent: true, noMarkup: true,
- contains: ['attribute'],
- relevance: 0,
- illegal: '[\\+\\.]'
- },
- hljs.XML_ATTR,
- hljs.XML_VALUE_QUOT,
- hljs.XML_VALUE_APOS
- ]
-};
-
-hljs.HTML_TAGS = {'code': 1, 'kbd': 1, 'font': 1, 'noscript': 1, 'style': 1, 'img': 1, 'title': 1, 'menu': 1, 'tt': 1, 'tr': 1, 'param': 1, 'li': 1, 'tfoot': 1, 'th': 1, 'input': 1, 'td': 1, 'dl': 1, 'blockquote': 1, 'fieldset': 1, 'big': 1, 'dd': 1, 'abbr': 1, 'optgroup': 1, 'dt': 1, 'button': 1, 'isindex': 1, 'p': 1, 'small': 1, 'div': 1, 'dir': 1, 'em': 1, 'frame': 1, 'meta': 1, 'sub': 1, 'bdo': 1, 'label': 1, 'acronym': 1, 'sup': 1, 'body': 1, 'xml': 1, 'basefont': 1, 'base': 1, 'br': 1, 'address': 1, 'strong': 1, 'legend': 1, 'ol': 1, 'script': 1, 'caption': 1, 's': 1, 'col': 1, 'h2': 1, 'h3': 1, 'h1': 1, 'h6': 1, 'h4': 1, 'h5': 1, 'table': 1, 'select': 1, 'noframes': 1, 'span': 1, 'area': 1, 'dfn': 1, 'strike': 1, 'cite': 1, 'thead': 1, 'head': 1, 'option': 1, 'form': 1, 'hr': 1, 'var': 1, 'link': 1, 'b': 1, 'colgroup': 1, 'ul': 1, 'applet': 1, 'del': 1, 'iframe': 1, 'pre': 1, 'frameset': 1, 'ins': 1, 'tbody': 1, 'html': 1, 'samp': 1, 'map': 1, 'object': 1, 'a': 1, 'xmlns': 1, 'center': 1, 'textarea': 1, 'i': 1, 'q': 1, 'u': 1};
-hljs.HTML_DOCTYPE = {
- className: 'doctype',
- begin: '<!DOCTYPE', end: '>',
- relevance: 10
-};
-hljs.HTML_ATTR = {
- className: 'attribute',
- begin: '\\s[a-zA-Z\\:_-]+=', end: '^',
- contains: ['value']
-};
-hljs.HTML_SHORT_ATTR = {
- className: 'attribute',
- begin: ' [a-zA-Z]+', end: '^'
-};
-hljs.HTML_VALUE = {
- className: 'value',
- begin: '[a-zA-Z0-9]+', end: '^'
-};
-
-hljs.LANGUAGES.html = {
- defaultMode: {
- contains: ['tag', 'comment', 'doctype', 'vbscript']
- },
- case_insensitive: true,
- modes: [
- hljs.XML_COMMENT,
- hljs.HTML_DOCTYPE,
- {
- className: 'tag',
- lexems: [hljs.IDENT_RE],
- keywords: hljs.HTML_TAGS,
- begin: '<style', end: '>',
- contains: ['attribute'],
- illegal: '[\\+\\.]',
- starts: 'css'
- },
- {
- className: 'tag',
- lexems: [hljs.IDENT_RE],
- keywords: hljs.HTML_TAGS,
- begin: '<script', end: '>',
- contains: ['attribute'],
- illegal: '[\\+\\.]',
- starts: 'javascript'
- },
- {
- className: 'tag',
- lexems: [hljs.IDENT_RE],
- keywords: hljs.HTML_TAGS,
- begin: '<[A-Za-z/]', end: '>',
- contains: ['attribute'],
- illegal: '[\\+\\.]'
- },
- {
- className: 'css',
- end: '</style>', returnEnd: true,
- subLanguage: 'css'
- },
- {
- className: 'javascript',
- end: '</script>', returnEnd: true,
- subLanguage: 'javascript'
- },
- hljs.HTML_ATTR,
- hljs.HTML_SHORT_ATTR,
- hljs.XML_VALUE_QUOT,
- hljs.XML_VALUE_APOS,
- hljs.HTML_VALUE,
- {
- className: 'vbscript',
- begin: '<%', end: '%>',
- subLanguage: 'vbscript'
- }
- ]
-};
-
-};
View
14 lib/vendor/highlight.js/languages/xml.js
@@ -1,9 +1,8 @@
/*
Language: HTML, XML
-Category: common
*/
-module.exports = function(hljs){
-hljs.LANGUAGES.xml = function(){
+
+module.exports = function (hljs) {
var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+';
var TAG_INTERNALS = {
endsWithParent: true,
@@ -36,7 +35,8 @@ hljs.LANGUAGES.xml = function(){
}
]
};
- return {
+
+ hljs.LANGUAGES.xml = {
case_insensitive: true,
defaultMode: {
contains: [
@@ -48,7 +48,8 @@ hljs.LANGUAGES.xml = function(){
{
className: 'doctype',
begin: '<!DOCTYPE', end: '>',
- relevance: 10
+ relevance: 10,
+ contains: [{begin: '\\[', end: '\\]'}]
},
{
className: 'comment',
@@ -100,5 +101,4 @@ hljs.LANGUAGES.xml = function(){
]
}
};
-}();
-};
+};
Please sign in to comment.
Something went wrong with that request. Please try again.