mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-17 08:05:19 +00:00
cf958bacd1
* Start * Use MathJax v3 * Format * Improve font-size * Lint * Better handle loading * Copy MathJax assets to public folder * Attempt at using local assets for MathJax * Use bun 1.0.31 * Try with bun 1.0.33 * Try fixing headers * Simplify * Simplify and not use suspense module * Cleanup more * Add test for Math * Make math block scroll if needed * Update packages/react-math/src/KaTeX.tsx Co-authored-by: Greg Bergé <berge.greg@gmail.com> * Use React.use * Format * Use exports * Lint * Disable cache in CI for lint * Format --------- Co-authored-by: Greg Bergé <berge.greg@gmail.com>
31 lines
886 B
TypeScript
31 lines
886 B
TypeScript
import { DocumentBlockMath, DocumentInlineMath } from '@gitbook/api';
|
|
|
|
import { getStaticFileURL } from '@/lib/assets';
|
|
import { tcls } from '@/lib/tailwind';
|
|
|
|
import { MathFormula } from '@gitbook/react-math';
|
|
|
|
import { BlockProps } from './Block';
|
|
import { InlineProps } from './Inline';
|
|
|
|
const mathJaxUrl = getStaticFileURL('mathjax@3.2.2/tex-chtml.js');
|
|
|
|
export async function BlockMath(props: BlockProps<DocumentBlockMath>) {
|
|
const { block, style } = props;
|
|
|
|
return (
|
|
<MathFormula
|
|
formula={block.data.formula}
|
|
inline={false}
|
|
className={tcls(style, 'overflow-x-auto')}
|
|
mathJaxUrl={mathJaxUrl}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export async function InlineMath(props: InlineProps<DocumentInlineMath>) {
|
|
const { inline } = props;
|
|
|
|
return <MathFormula formula={inline.data.formula} inline={true} mathJaxUrl={mathJaxUrl} />;
|
|
}
|