Skip to content

Invert test logic for auto-detection #1438

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

Merged
merged 1 commit into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
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
27 changes: 16 additions & 11 deletions libs/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ renderer.link = function (aHref, aTitle, aText) {
marked.setOptions({
highlight: function (aCode, aLang) {
var obj = null;
var lang = [ // NOTE: More likely to less likely
'javascript', 'xpath', 'xml',
'css', 'less', 'scss',
'json',
'diff',
'shell',
'bash', 'dos',
'vbscript'
];

if (aLang && hljs.getLanguage(aLang)) {
try {
Expand All @@ -162,17 +171,13 @@ marked.setOptions({
try {
obj = hljs.highlightAuto(aCode);

switch (obj.language) {
// Transform list of auto-detected language highlights
case 'dust':
case '1c':
case 'qml':
// Narrow auto-detection to something that is more likely
return hljs.highlightAuto(aCode, ['css', 'html', 'js', 'json']).value;
break;
// Any other detected go ahead and return
default:
return obj.value;
if (lang.indexOf(obj.language) > -1) {
return obj.value;
} else {
if (isDev) {
console.log('Unusual auto-detected md language code is', '`' + obj.language + '`');
}
return hljs.highlightAuto(aCode, lang).value;
}
} catch (aErr) {
}
Expand Down
2 changes: 1 addition & 1 deletion views/includes/documents/Frequently-Asked-Questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var thisIsJavascript = "yahoo!";

... instead of:

```
``` ebnf
var thisIsJavascript = "yahoo!";
```

Expand Down