mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
refactor(read_only_code): use Set for selfClosingTags check
* moved it outside of the replacer, so that it does not need get created on each iteration of the replacer (as it gets run for each single match)
This commit is contained in:
parent
480f1e4ce1
commit
f5cb845659
@ -66,6 +66,8 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget {
|
||||
let i = 0;
|
||||
let pre: { indent: string; tag: string }[] = [];
|
||||
|
||||
const selfClosingTags = new Set(["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr"]);
|
||||
|
||||
html = html
|
||||
// match everything, including whitespace/newline characters
|
||||
.replace(/<pre>((.)+)?<\/pre>/s, (match) => {
|
||||
@ -83,7 +85,7 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget {
|
||||
pre[pInd].indent = indent;
|
||||
}
|
||||
|
||||
if (["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr"].indexOf(tag) >= 0) {
|
||||
if (selfClosingTags.has(tag)) {
|
||||
// self closing tag
|
||||
ret = indent + x;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user