Skip to content

Commit 77bd325

Browse files
committed
b64-encode render ids to avoid escaping issues
1 parent 412ea63 commit 77bd325

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/core/markdown-pipeline.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
*
44
* Copyright (C) 2020-2022 Posit Software, PBC
55
*/
6+
import { base } from "acorn/walk";
7+
import { decodeBase64, encodeBase64 } from "encoding/base64";
68
import { Document, Element, Node } from "./deno-dom.ts";
9+
import { decode } from "https://deno.land/std@0.93.0/encoding/base64.ts";
710

811
export interface PipelineMarkdown {
912
blocks?: Record<string, string>;
@@ -98,10 +101,12 @@ export function processMarkdownRenderEnvelope(
98101
const markdownEnvelopeWriter = (envelopeId: string) => {
99102
const renderList: string[] = [];
100103
const hiddenSpan = (id: string, contents: string) => {
104+
id = encodeBase64(id);
101105
return `[${contents}]{.hidden .quarto-markdown-envelope-contents render-id="${id}"}`;
102106
};
103107

104108
const hiddenDiv = (id: string, contents: string) => {
109+
id = encodeBase64(id);
105110
return `\n:::{.hidden .quarto-markdown-envelope-contents render-id="${id}"}\n${contents}\n:::\n`;
106111
};
107112

@@ -126,7 +131,8 @@ const readEnvelope = (doc: Document, envelopeId: string) => {
126131
const el = node as Element;
127132
const id = el.getAttribute("data-render-id");
128133
if (id) {
129-
contents[id] = el;
134+
// convert the array to a string
135+
contents[new TextDecoder().decode(decodeBase64(id))] = el;
130136
}
131137
};
132138

0 commit comments

Comments
 (0)