-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11097 from quarto-dev/bugfix/8932
markdown pipeline: escape render-ids
- Loading branch information
Showing
7 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,10 @@ | |
* | ||
* Copyright (C) 2020-2022 Posit Software, PBC | ||
*/ | ||
import { base } from "acorn/walk"; | ||
import { decodeBase64, encodeBase64 } from "encoding/base64"; | ||
import { Document, Element, Node } from "./deno-dom.ts"; | ||
import { decode } from "https://deno.land/[email protected]/encoding/base64.ts"; | ||
|
||
export interface PipelineMarkdown { | ||
blocks?: Record<string, string>; | ||
|
@@ -98,10 +101,12 @@ export function processMarkdownRenderEnvelope( | |
const markdownEnvelopeWriter = (envelopeId: string) => { | ||
const renderList: string[] = []; | ||
const hiddenSpan = (id: string, contents: string) => { | ||
id = encodeBase64(id); | ||
return `[${contents}]{.hidden .quarto-markdown-envelope-contents render-id="${id}"}`; | ||
}; | ||
|
||
const hiddenDiv = (id: string, contents: string) => { | ||
id = encodeBase64(id); | ||
return `\n:::{.hidden .quarto-markdown-envelope-contents render-id="${id}"}\n${contents}\n:::\n`; | ||
}; | ||
|
||
|
@@ -126,7 +131,8 @@ const readEnvelope = (doc: Document, envelopeId: string) => { | |
const el = node as Element; | ||
const id = el.getAttribute("data-render-id"); | ||
if (id) { | ||
contents[id] = el; | ||
// convert the array to a string | ||
contents[new TextDecoder().decode(decodeBase64(id))] = el; | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
project: | ||
type: website | ||
|
||
website: | ||
title: "issue-8932" | ||
navbar: | ||
left: | ||
- href: index.qmd | ||
text: Home | ||
- about.qmd | ||
page-footer: | ||
center: | ||
- text: 'Project "created"' | ||
|
||
format: | ||
html: | ||
theme: cosmo | ||
css: styles.css | ||
toc: true | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: "About" | ||
--- | ||
|
||
About this site |
5 changes: 5 additions & 0 deletions
5
tests/docs/smoke-all/2024/10/17/issue-8932/check_stray_div.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function Str(str) | ||
if string.find(str.text, ":::") then | ||
crash() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: "issue-8932" | ||
filters: | ||
- check_stray_div.lua | ||
--- | ||
|
||
This is a Quarto website. | ||
|
||
To learn more about Quarto websites visit <https://quarto.org/docs/websites>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* css styles */ |