mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-10-24 03:06:22 +02:00
Highlight sample code
This commit is contained in:
11
client/helpers/highlight.js
Executable file
11
client/helpers/highlight.js
Executable file
@@ -0,0 +1,11 @@
|
||||
import hljs from 'highlight.js';
|
||||
|
||||
const highlight = (input, language) => {
|
||||
const lang = language || 'html';
|
||||
const { value } = hljs.highlight(lang, input);
|
||||
const highlighted = value.replace('&', '&').trim();
|
||||
|
||||
return `<code class="hljs ${lang}">${highlighted}</code>`;
|
||||
};
|
||||
|
||||
export default highlight;
|
||||
Reference in New Issue
Block a user