Skip to content

Commit fea63f3

Browse files
committed
doc: fix katex example issue. (#106)
1 parent 12a88c6 commit fea63f3

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

core/README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -597,18 +597,14 @@ export default function App() {
597597
onChange={(val) => setValue(val)}
598598
previewOptions={{
599599
components: {
600-
code: ({ inline, children = [], className, ...props }) => {
601-
const txt = children[0] || '';
602-
if (inline) {
603-
if (typeof txt === 'string' && /^\$\$(.*)\$\$/.test(txt)) {
604-
const html = katex.renderToString(txt.replace(/^\$\$(.*)\$\$/, '$1'), {
605-
throwOnError: false,
606-
});
607-
return <code dangerouslySetInnerHTML={{ __html: html }} />;
608-
}
609-
return <code>{txt}</code>;
600+
code: ({ children = [], className, ...props }) => {
601+
if (typeof children === 'string' && /^\$\$(.*)\$\$/.test(children)) {
602+
const html = katex.renderToString(children.replace(/^\$\$(.*)\$\$/, '$1'), {
603+
throwOnError: false,
604+
});
605+
return <code dangerouslySetInnerHTML={{ __html: html }} style={{ background: 'transparent' }} />;
610606
}
611-
const code = props.node && props.node.children ? getCodeString(props.node.children) : txt;
607+
const code = props.node && props.node.children ? getCodeString(props.node.children) : children;
612608
if (
613609
typeof code === 'string' &&
614610
typeof className === 'string' &&
@@ -732,7 +728,6 @@ const Code = ({ inline, children = [], className, ...props }) => {
732728
mermaid
733729
.render(demoid.current, code)
734730
.then(({ svg, bindFunctions }) => {
735-
console.log("svg:", svg);
736731
container.innerHTML = svg;
737732
if (bindFunctions) {
738733
bindFunctions(container);

0 commit comments

Comments
 (0)