Rich message rendering #24
1 changed files with 13 additions and 1 deletions
|
@ -12,8 +12,20 @@ class HighlightedCode extends ElemJS {
|
||||||
this.element.appendChild(child)
|
this.element.appendChild(child)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.element.textContent.length > 80) {
|
||||||
|
/*
|
||||||
|
no need to highlight very short code blocks:
|
||||||
|
- content inside might not be code, some users still use code blocks
|
||||||
|
for plaintext quotes
|
||||||
|
- language detection will almost certainly be incorrect
|
||||||
|
- even if it's code and the language is detected, the user will
|
||||||
|
be able to mentally format small amounts of code themselves
|
||||||
|
|
||||||
|
feel free to change the threshold number
|
||||||
|
*/
|
||||||
lazyLoad("./static/hljs.js").then(hljs => hljs.highlightBlock(this.element))
|
lazyLoad("./static/hljs.js").then(hljs => hljs.highlightBlock(this.element))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {HighlightedCode}
|
module.exports = {HighlightedCode}
|
||||||
|
|
Loading…
Reference in a new issue