Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import scss from "highlight.js/lib/languages/scss.js";
import stylus from "highlight.js/lib/languages/stylus.js";
import js from "highlight.js/lib/languages/javascript.js";
import ts from "highlight.js/lib/languages/typescript.js";
import json from "highlight.js/lib/languages/json.js";
import xml from "highlight.js/lib/languages/xml.js";
import md from "highlight.js/lib/languages/markdown.js";
import bash from "highlight.js/lib/languages/bash.js";
// CSS and friends
low.registerLanguage("css", css);
low.registerLanguage("less", less);
low.registerLanguage("scss", scss);
low.registerLanguage("stylus", stylus);
// JS and friends
low.registerLanguage("js", js);
low.registerLanguage("javascript", js);
low.registerLanguage("jsx", js);
low.registerLanguage("ts", ts);
low.registerLanguage("tsx", ts);
low.registerLanguage("typescript", ts);
low.registerLanguage("json", json);
// HTML and friends
low.registerLanguage("html", xml);
low.registerLanguage("xml", xml);
low.registerLanguage("md", md);
low.registerLanguage("markdown", md);
low.registerLanguage("stylus", stylus);
// JS and friends
low.registerLanguage("js", js);
low.registerLanguage("javascript", js);
low.registerLanguage("jsx", js);
low.registerLanguage("ts", ts);
low.registerLanguage("tsx", ts);
low.registerLanguage("typescript", ts);
low.registerLanguage("json", json);
// HTML and friends
low.registerLanguage("html", xml);
low.registerLanguage("xml", xml);
low.registerLanguage("md", md);
low.registerLanguage("markdown", md);
// (s)hell(ish)s
low.registerLanguage("bash", bash);
// Low.registerLanguage('shell', bash);
const languages = [
"css",
"less",
"scss",
"stylus",
"js",
"javascript",
"jsx",
"ts",
"tsx",
"typescript",
import json from "highlight.js/lib/languages/json.js";
import xml from "highlight.js/lib/languages/xml.js";
import md from "highlight.js/lib/languages/markdown.js";
import bash from "highlight.js/lib/languages/bash.js";
// CSS and friends
low.registerLanguage("css", css);
low.registerLanguage("less", less);
low.registerLanguage("scss", scss);
low.registerLanguage("stylus", stylus);
// JS and friends
low.registerLanguage("js", js);
low.registerLanguage("javascript", js);
low.registerLanguage("jsx", js);
low.registerLanguage("ts", ts);
low.registerLanguage("tsx", ts);
low.registerLanguage("typescript", ts);
low.registerLanguage("json", json);
// HTML and friends
low.registerLanguage("html", xml);
low.registerLanguage("xml", xml);
low.registerLanguage("md", md);
low.registerLanguage("markdown", md);
// (s)hell(ish)s
low.registerLanguage("bash", bash);
// Low.registerLanguage('shell', bash);
const hast = highlight(language, source);
return toElements(hast);
}
// Highlight configuration
// CSS and friends
low.registerLanguage('css', css);
low.registerLanguage('less', less);
low.registerLanguage('scss', scss);
low.registerLanguage('stylus', stylus);
// JS and friends
low.registerLanguage('js', js);
low.registerLanguage('javascript', js);
low.registerLanguage('jsx', js);
low.registerLanguage('ts', ts);
low.registerLanguage('tsx', ts);
low.registerLanguage('typescript', ts);
low.registerLanguage('json', json);
// HTML and friends
low.registerLanguage('html', xml);
low.registerLanguage('xml', xml);
low.registerLanguage('md', md);
low.registerLanguage('markdown', md);
// (s)hell(ish)s
low.registerLanguage('bash', bash);
// Low.registerLanguage('shell', bash);
const languages = ['css', 'less', 'scss', 'stylus', 'js', 'javascript', 'jsx', 'ts', 'tsx', 'typescript', 'json', 'html', 'xml', 'md', 'markdown', 'bash'];
}
// Highlight configuration
// CSS and friends
low.registerLanguage('css', css);
low.registerLanguage('less', less);
low.registerLanguage('scss', scss);
low.registerLanguage('stylus', stylus);
// JS and friends
low.registerLanguage('js', js);
low.registerLanguage('javascript', js);
low.registerLanguage('jsx', js);
low.registerLanguage('ts', ts);
low.registerLanguage('tsx', ts);
low.registerLanguage('typescript', ts);
low.registerLanguage('json', json);
// HTML and friends
low.registerLanguage('html', xml);
low.registerLanguage('xml', xml);
low.registerLanguage('md', md);
low.registerLanguage('markdown', md);
// (s)hell(ish)s
low.registerLanguage('bash', bash);
// Low.registerLanguage('shell', bash);
const languages = ['css', 'less', 'scss', 'stylus', 'js', 'javascript', 'jsx', 'ts', 'tsx', 'typescript', 'json', 'html', 'xml', 'md', 'markdown', 'bash'];
function highlight(language, source) {
inlineTokenRules['fence'] = function(token, env) {
const style = getStyle(token, {fontFamily: 'Courier New'});
startStyle(style, env);
const language = token.info ? token.info.trim() : undefined;
if(language) {
const htmlTokens = low.highlight(language, token.content);
for(let token of htmlTokens.value) {
processHtmlToken(token, env);
}
} else {
// For code blocks, replace line feeds with vertical tabs to keep
// the block as a single paragraph. This avoid the extra vertical
// space that appears between paragraphs
env.text.rawText += token.content.replace(/\n/g, '\u000b');
}
env.text.rawText += '\n';
endStyle(env);
};
'use strict'
var chalk = require('chalk')
var lowlight = require('lowlight/lib/core.js')
var high = lowlight.highlight
var auto = lowlight.highlightAuto
// Inherit.
function Lowlight() {}
Lowlight.prototype = lowlight
var emphasize = new Lowlight()
// Expose.
module.exports = emphasize
emphasize.highlight = highlight
emphasize.highlightAuto = highlightAuto
// Default style sheet.
'use strict'
var chalk = require('chalk')
var lowlight = require('lowlight/lib/core.js')
var high = lowlight.highlight
var auto = lowlight.highlightAuto
// Inherit.
function Lowlight() {}
Lowlight.prototype = lowlight
var emphasize = new Lowlight()
// Expose.
module.exports = emphasize
emphasize.highlight = highlight
emphasize.highlightAuto = highlightAuto
// Default style sheet.
var defaultSheet = {
keywords: {
keyword:
'forall all exists exist only m M i e 1 2 3 4 5 6 7 8 9 0 - + * / \ % ! . , ; : | lim limsup liminf infinity not'
},
contains: [
{
className: 'variable',
begin: '(', end: ')'
},
]
};
}
registerLanguage('math', highlighter);
console.log(highlight('typescript',
`class CPP {
private year: number;
public constructor(private version: string) {
this.year = Number(version.match(/.+\d+$/));
}
public version(): string {
return this.version;
}
}
`
));
console.info(highlightAuto(
`class CPP {
private year: number;
`class CPP {
private year: number;
public constructor(private version: string) {
this.year = Number(version.match(/.+\d+$/));
}
public version(): string {
return this.version;
}
}
`
));
core.registerLanguage('math', highlighter);
console.log(core.highlight('javascript',
`class CPP {
constructor(version) {
this.version = version;
this.year = Number(version.match(/.+\d+$/));
}
version(){
return this.version;
}
}
`
, { prefix: 'core-' }));
console.info(core.highlightAuto(
`class CPP {