mirror of
https://github.com/zadam/trilium.git
synced 2025-11-21 16:14:23 +01:00
fix(share): syntax highlighting doesn't unescape properly (closes #7783)
This commit is contained in:
parent
84b3d6db76
commit
623da7eade
@ -81,6 +81,35 @@ describe("content_renderer", () => {
|
|||||||
<p>After</p>
|
<p>After</p>
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("handles syntax highlight for code blocks with escaped syntax", () => {
|
||||||
|
const note = buildShareNote({
|
||||||
|
id: "note",
|
||||||
|
content: trimIndentation`\
|
||||||
|
<h2>
|
||||||
|
Defining the options
|
||||||
|
</h2>
|
||||||
|
<pre>
|
||||||
|
<code class="language-text-x-trilium-auto"><t t-name="module.SectionWidthOption">
|
||||||
|
<BuilderRow label.translate="Section Width">
|
||||||
|
</BuilderRow>
|
||||||
|
</t></code>
|
||||||
|
</pre>
|
||||||
|
`
|
||||||
|
});
|
||||||
|
const result = getContent(note);
|
||||||
|
expect(result.content).toStrictEqual(trimIndentation`\
|
||||||
|
<h2>
|
||||||
|
Defining the options
|
||||||
|
</h2>
|
||||||
|
<pre>
|
||||||
|
<code class="language-text-x-trilium-auto hljs"><span class="hljs-tag"><<span class="hljs-name">t</span> <span class="hljs-attr">t-name</span>=<span class="hljs-string">"module.SectionWidthOption"</span>></span>
|
||||||
|
<span class="hljs-tag"><<span class="hljs-name">BuilderRow</span> <span class="hljs-attr">label.translate</span>=<span class="hljs-string">"Section Width"</span>></span>
|
||||||
|
<span class="hljs-tag"></<span class="hljs-name">BuilderRow</span>></span>
|
||||||
|
<span class="hljs-tag"></<span class="hljs-name">t</span>></span></code>
|
||||||
|
</pre>
|
||||||
|
`)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("renderCode", () => {
|
describe("renderCode", () => {
|
||||||
|
|||||||
@ -330,7 +330,7 @@ function renderText(result: Result, note: SNote | BNote) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const highlightResult = highlightAuto(codeEl.innerText);
|
const highlightResult = highlightAuto(codeEl.text);
|
||||||
codeEl.innerHTML = highlightResult.value;
|
codeEl.innerHTML = highlightResult.value;
|
||||||
codeEl.classList.add("hljs");
|
codeEl.classList.add("hljs");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user