Tycho fixes

This commit is contained in:
Nate Moore 2021-09-17 22:32:33 +00:00 committed by Drew Powers
parent 1581095d72
commit f25550080b
4 changed files with 5 additions and 3 deletions

View file

@ -21,6 +21,6 @@ export async function renderToString(result: any, componentFactory: AstroCompone
export async function renderPage(result: any, Component: AstroComponentFactory, props: any, children: any) { export async function renderPage(result: any, Component: AstroComponentFactory, props: any, children: any) {
const template = await renderToString(result, Component, props, children); const template = await renderToString(result, Component, props, children);
const styles = Array.from(result.styles).map((style) => `<style>${style}</style>`); const styles = Array.from(result.styles).map((style) => `<style>${style}</style>`);
const scripts = Array.from(result.scripts); const scripts = Array.from(result.scripts).map((script) => `<script type="module">${script}</script>`);
return template.replace('</head>', styles.join('\n') + scripts.join('\n') + '</head>'); return template.replace('</head>', styles.join('\n') + scripts.join('\n') + '</head>');
} }

View file

@ -23,7 +23,7 @@ export function rehypeCodeBlock() {
const escapeCode = (code: Element): void => { const escapeCode = (code: Element): void => {
code.children = code.children.map((child) => { code.children = code.children.map((child) => {
if (child.type === 'text') { if (child.type === 'text') {
return { ...child, value: child.value.replace(/\{/g, '&lbrace;') }; return { ...child, value: `{\`${child.value.replace(/\$\{/g, '\\$\\{').replace(/`/g, '\\`')}\`}` };
} }
return child; return child;
}); });

View file

@ -29,7 +29,7 @@ export const DEFAULT_REMARK_PLUGINS = [
'remark-gfm', 'remark-gfm',
'remark-footnotes', 'remark-footnotes',
// TODO: reenable smartypants! // TODO: reenable smartypants!
'@silvenon/remark-smartypants' // '@silvenon/remark-smartypants'
] ]
export const DEFAULT_REHYPE_PLUGINS = [ export const DEFAULT_REHYPE_PLUGINS = [

View file

@ -16,6 +16,8 @@ export default function rehypeJsx(): any {
let attr = entry.value; let attr = entry.value;
if (attr && typeof attr === 'object') { if (attr && typeof attr === 'object') {
attr = `{${attr.value}}` attr = `{${attr.value}}`
} else if (attr === null) {
attr = `{true}`
} }
return Object.assign(acc, { [entry.name]: attr }); return Object.assign(acc, { [entry.name]: attr });
}, {}) }, {})