mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
Markdoc: strip HTML comments from output (#7224)
* feat: strip HTML comments from output * chore: changeset
This commit is contained in:
parent
290e344dee
commit
563293c5d6
2 changed files with 13 additions and 1 deletions
5
.changeset/many-cats-fry.md
Normal file
5
.changeset/many-cats-fry.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/markdoc': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Allow HTML comments `<!--like this-->` in Markdoc files.
|
|
@ -19,6 +19,12 @@ type SetupHookParams = HookParameters<'astro:config:setup'> & {
|
||||||
addContentEntryType: (contentEntryType: ContentEntryType) => void;
|
addContentEntryType: (contentEntryType: ContentEntryType) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const markdocTokenizer = new Markdoc.Tokenizer({
|
||||||
|
// Strip <!-- comments --> from rendered output
|
||||||
|
// Without this, they're rendered as strings!
|
||||||
|
allowComments: true,
|
||||||
|
});
|
||||||
|
|
||||||
export default function markdocIntegration(legacyConfig?: any): AstroIntegration {
|
export default function markdocIntegration(legacyConfig?: any): AstroIntegration {
|
||||||
if (legacyConfig) {
|
if (legacyConfig) {
|
||||||
console.log(
|
console.log(
|
||||||
|
@ -64,7 +70,8 @@ export default function markdocIntegration(legacyConfig?: any): AstroIntegration
|
||||||
getEntryInfo,
|
getEntryInfo,
|
||||||
async getRenderModule({ contents, fileUrl, viteId }) {
|
async getRenderModule({ contents, fileUrl, viteId }) {
|
||||||
const entry = getEntryInfo({ contents, fileUrl });
|
const entry = getEntryInfo({ contents, fileUrl });
|
||||||
const ast = Markdoc.parse(entry.body);
|
const tokens = markdocTokenizer.tokenize(entry.body);
|
||||||
|
const ast = Markdoc.parse(tokens);
|
||||||
const pluginContext = this;
|
const pluginContext = this;
|
||||||
const markdocConfig = await setupConfig(userMarkdocConfig);
|
const markdocConfig = await setupConfig(userMarkdocConfig);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue