mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
refactor(read_only_code): simplify first format replacer
* simplified regex, by using the `s` flag * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#advanced_searching_with_flags * use template literal instead of string concat * use arrow function
This commit is contained in:
parent
3fec958fb3
commit
480f1e4ce1
@ -67,9 +67,10 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget {
|
||||
let pre: { indent: string; tag: string }[] = [];
|
||||
|
||||
html = html
|
||||
.replace(new RegExp("<pre>((.|\\t|\\n|\\r)+)?</pre>"), function (x) {
|
||||
pre.push({ indent: "", tag: x });
|
||||
return "<--TEMPPRE" + i++ + "/-->";
|
||||
// match everything, including whitespace/newline characters
|
||||
.replace(/<pre>((.)+)?<\/pre>/s, (match) => {
|
||||
pre.push({ indent: "", tag: match });
|
||||
return `<--TEMPPRE${i++}/-->`;
|
||||
})
|
||||
.replace(new RegExp("<[^<>]+>[^<]?", "g"), function (x) {
|
||||
let ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user