本文整理汇总了TypeScript中highlight.js.default类的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default类的具体用法?TypeScript js.default怎么用?TypeScript js.default使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了js.default类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
highlight: function(str: string, lang: string) {
if (lang && HighlightJS.getLanguage(lang)) {
try {
return HighlightJS.highlight(lang, str).value
} catch (__) { }
}
return ''; // use external default escaping
}
示例2: function
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (__) {
}
}
return ''; // use external default escaping
},
示例3: catch
highlight: (str: string, lang: string) => {
if (lang && hljs.getLanguage(lang)) {
try {
return `<pre class="hljs"><code><div>${hljs.highlight(lang, str, true).value}</div></code></pre>`;
} catch (error) { }
}
return `<pre class="hljs"><code><div>${this.engine.utils.escapeHtml(str)}</div></code></pre>`;
}
示例4: function
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return `<pre class="hljs"><code>${hljs.highlight(lang, str, true).value}</code></pre>`;
} catch (error) { }
}
return `<pre class="hljs"><code>${md.utils.escapeHtml(str)}</code></pre>`;
}
示例5:
renderer.code = (code, language) => {
// Check whether the given language is valid for highlight.js.
const validLang = !!(language && hljs.getLanguage(language));
language = validLang ? language : 'html'; // Default to html
// Highlight only if the language is valid.
const highlighted = hljs.highlight(language, code).value;
// Render the highlighted code with `hljs` class.
return `<pre><code class="hljs ${language}">${highlighted}</code></pre>`;
};
示例6: function
var hlight = function(code:string,language:string) {
var hljs = require('highlight.js');
var html;
if (typeof language === "undefined") {
html = (hljs.highlight(language, code)).value;
}
else {
html = (hljs.highlightAuto(code)).value;
};
return html2console('<pre class="hljs">' + html + '</pre>');
};
示例7:
highlight: (code: string, language: string): string => {
if (language) {
return highlightJs.highlight(
language.toLowerCase() === 'ts' ? 'typescript' : language, code).value;
}
return code;
}
示例8: highlightCodeBlock
export function highlightCodeBlock(code: string, language: string) {
if (language) {
return highlightJs.highlight(
language.toLowerCase() === 'ts' ? 'typescript' : language, code).value;
}
return code;
}
示例9:
highlight: (code: string, language: string) => {
if (language) {
// highlight.js expects "typescript" written out, while Github supports "ts".
let lang = language.toLowerCase() === 'ts' ? 'typescript' : language;
return hljs.highlight(lang, code).value;
}
return code;
}
示例10: function
highlight: function(code, lang) {
try {
let hljs = require('highlight.js');
return hljs.highlightAuto(code, [lang]).value;
}
catch (e) {
return code;
}
}