mirror of
https://github.com/TriliumNext/Trilium.git
synced 2026-10-12 02:09:59 +00:00
The HTML export pretty-prints with the `html` package, a 2013 fork of the
js-beautifier. When its 70-column wrap falls inside an inline tag it
emits a newline there (`<code\n spellcheck="false">`), and the tag-name
check then does `indexOf(' ')`, reads the name as `code\n`, misses the
inline-tag list and formats the tag as a block: a newline before it and
the space after `</code>` dropped. The bundled help had 150 such joins
("dateModifiedor", "localhost:8080is completed").
A pnpm patch changes the lookup to `search(/\s/)`, so the name is read up
to any whitespace and the tag keeps its inline treatment. The line break
inside the tag is left as it was; taking it out as well would move wrap
points across most of the help pages for no gain in readability.
A spec formats a paragraph whose wrap point lands inside a `<code>` and
checks the boundary survives; it fails on the unpatched package.
(cherry picked from commit 8cf4063fcd47cf1ca6a0438aa1fe626a2ebc532c)
16 lines
707 B
Diff
16 lines
707 B
Diff
diff --git a/lib/html.js b/lib/html.js
|
|
index 455c1ae8e1d23cb57bf71c0421d5a7430e86c3f4..8de8b08a283eea8e115c3e1545a6e8e9d77bbe06 100644
|
|
--- a/lib/html.js
|
|
+++ b/lib/html.js
|
|
@@ -227,8 +227,8 @@ function style_html(html_source, options) {
|
|
|
|
var tag_complete = content.join('');
|
|
var tag_index;
|
|
- if (tag_complete.indexOf(' ') != -1) { //if there's whitespace, thats where the tag name ends
|
|
- tag_index = tag_complete.indexOf(' ');
|
|
+ if (tag_complete.search(/\s/) != -1) { //if there's whitespace, thats where the tag name ends
|
|
+ tag_index = tag_complete.search(/\s/);
|
|
}
|
|
else { //otherwise go with the tag ending
|
|
tag_index = tag_complete.indexOf('>');
|