Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to non-alias xpath of xquery base for *highlight.js* dep #1529

Merged
merged 1 commit into from
Oct 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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