Skip to content

Build your personal knowledge base with Trilium Notes

fix(export): read an inline tag's name up to any whitespace

BeatLink5505053c6bfb
diff --git a/packages/trilium-core/src/services/export/zip/html.spec.ts b/packages/trilium-core/src/services/export/zip/html.spec.ts
index 7922af7086..0fad213fc0 100644
--- a/packages/trilium-core/src/services/export/zip/html.spec.ts
+++ b/packages/trilium-core/src/services/export/zip/html.spec.ts
@@ -96,6 +96,21 @@ describe("HtmlExportProvider", () => {
expect(rewriteFn.mock.calls[0][1]).toBe(noteMeta);
});
+ it("keeps the space after an inline tag that the pretty-printer wraps inside of", () => {
+ const { provider } = buildProvider({ zipExportOptions: { skipHtmlTemplate: true } });
+ const noteMeta: NoteMeta = { format: "html", notePath: ["root", "leaf"] };
+ // Long enough that the 70-column wrap lands inside the third <code> tag.
+ const content = "<p>When given a value, it will sort by other criteria instead: a comma-separated "
+ + "list of levels, each <code spellcheck=\"false\">title</code>, "
+ + "<code spellcheck=\"false\">dateCreated</code>, "
+ + "<code spellcheck=\"false\">dateModified</code> or the name of a label on the child notes.</p>";
+
+ const result = provider.prepareContent("Sorting", content, noteMeta) as string;
+
+ expect(result).not.toMatch(/<\/code>[A-Za-z]/);
+ expect(result.replace(/\s+/g, " ")).toContain("</code> or the name of a label");
+ });
+
it("uses a bare style.css path for a top-level note (notePath length 1)", () => {
const { provider } = buildProvider();
const result = provider.prepareContent("T", "<p>x</p>", {
diff --git a/patches/[email protected] b/patches/[email protected]
new file mode 100644
index 0000000000..09306fb4bc
--- /dev/null
+++ b/patches/[email protected]
@@ -0,0 +1,15 @@
+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('>');
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 726ea43ccf..e28642f55e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -85,6 +85,7 @@ overrides:
patchedDependencies:
'@excalidraw/[email protected]': 859531a8ff622291b895d36bcd33e07ced6fcb3bcc90631ccaf776789b03f0c2
+ [email protected]: 8acc288f8e9cde3c8a0c6e89f0b3796aeeb8251b88db9d1ba313e2352a591d68
importers:
@@ -733,7 +734,7 @@ importers:
version: 8.3.0
html:
specifier: 1.0.0
- version: 1.0.0
+ version: 1.0.0(patch_hash=8acc288f8e9cde3c8a0c6e89f0b3796aeeb8251b88db9d1ba313e2352a591d68)
http-proxy-agent:
specifier: 9.1.0
version: 9.1.0([email protected])
@@ -21155,7 +21156,7 @@ snapshots:
+ [email protected](patch_hash=8acc288f8e9cde3c8a0c6e89f0b3796aeeb8251b88db9d1ba313e2352a591d68):
dependencies:
concat-stream: 1.6.2
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 82d2d72f39..6f7d43be32 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -123,6 +123,7 @@ ignoredOptionalDependencies:
patchedDependencies:
'@excalidraw/[email protected]': patches/@[email protected]
allowBuilds:
"@parcel/watcher": false