mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-10-23 10:46:13 +02:00
15 lines
503 B
TypeScript
Executable File
15 lines
503 B
TypeScript
Executable File
import hljs from 'highlight.js/lib/highlight'; // tslint:disable-line
|
|
import html from 'highlight.js/lib/languages/xml'; // tslint:disable-line
|
|
|
|
hljs.registerLanguage('html', html);
|
|
|
|
const highlight = (input: string, language: string) => {
|
|
const lang = language || 'html';
|
|
const { value } = hljs.highlight(lang, input);
|
|
const highlighted = value.replace('&', '&').trim();
|
|
|
|
return `<code style="height: 100%" class="hljs ${lang}">${highlighted}</code>`;
|
|
};
|
|
|
|
export default highlight;
|