Skip to content

Commit

Permalink
Fix to non-alias xpath of xquery base for *highlight.js* dep
Browse files Browse the repository at this point in the history
* Add in some dev console messages to assist

Post OpenUserJS#1528 OpenUserJS#1438 ; Applies to OpenUserJS#430 ; See also highlightjs/highlight.js#1868
  • Loading branch information
Martii committed Oct 14, 2018
1 parent c5cb49c commit edcd436
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions libs/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var _ = require('underscore');
var marked = require('marked');
var hljs = require('highlight.js');
var sanitizeHtml = require('sanitize-html');
var colors = require('ansi-colors');

var isSameOrigin = require('./helpers').isSameOrigin;

Expand Down Expand Up @@ -225,7 +226,7 @@ marked.setOptions({
highlight: function (aCode, aLang) {
var obj = null;
var lang = [ // NOTE: More likely to less likely
'javascript', 'xpath', 'xml',
'javascript', 'xquery', 'xml',
'css', 'less', 'scss',
'json',
'diff',
Expand All @@ -238,6 +239,13 @@ marked.setOptions({
try {
return hljs.highlight(aLang, aCode).value;
} catch (aErr) {
if (isDev) {
console.error([
colors.red('Dependency named highlighting failed with:'),
aErr

].join('\n'));
}
}
}

Expand All @@ -248,11 +256,22 @@ marked.setOptions({
return obj.value;
} else {
if (isDev) {
console.log('Unusual auto-detected md language code is', '`' + obj.language + '`');
console.log([
colors.yellow('Unusual auto-detected md language code is')
+ '`' + colors.cyan(obj.language) + '`',

].join('\n'));
}
return hljs.highlightAuto(aCode, lang).value;
}
} catch (aErr) {
if (isDev) {
console.error([
colors.red('Dependency automatic named highlighting failed with:'),
aErr

].join('\n'));
}
}

// If any external package failure don't block return e.g. prevent empty
Expand Down

0 comments on commit edcd436

Please sign in to comment.