Skip to content

Commit

Permalink
🐛 Fix HTML rendering in JupyterLab
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 committed Mar 21, 2023
1 parent 3447eb4 commit 2fd6674
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/myst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
RRIDTransformer,
linksPlugin,
ReferenceState,
getFrontmatter,
htmlPlugin
getFrontmatter
// htmlPlugin
} from 'myst-transforms';
import { unified } from 'unified';
import { VFile } from 'vfile';
Expand Down Expand Up @@ -56,15 +56,15 @@ export function markdownParse(text: string): Root {
// This is consistent with the current Jupyter markdown renderer
unified()
.use(basicTransformationsPlugin)
.use(htmlPlugin, {
htmlHandlers: {
comment(h: any, node: any) {
const result = h(node, 'comment');
(result as any).value = node.value;
return result;
}
}
})
// .use(htmlPlugin, {
// htmlHandlers: {
// comment(h: any, node: any) {
// const result = h(node, 'comment');
// (result as any).value = node.value;
// return result;
// }
// }
// })
.runSync(mdast as any);
return mdast as Root;
}
Expand Down
4 changes: 4 additions & 0 deletions src/renderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ export const renderers: Record<string, NodeRenderer> = {
mermaid: MermaidNodeRenderer,
inlineExpression: (node, children) => {
return <InlineRenderer value={node.value} />;
},
html: (node, children) => {
// TODO: This needs to be sanitized properly
return <span dangerouslySetInnerHTML={{ __html: node.value }}></span>;
}
};

0 comments on commit 2fd6674

Please sign in to comment.