Markdown for Astrohacker
npm install astrohacker-mdThis is a fork of markdown-to-jsx that adds support for block- and inline-level
mathematics to markdown files using span tags that can be rendered with KaTeX
inside a browser as well as other features used by Astrohacker.
An example of how to use this library inside your Remix project to support math
and links is as follows:
``jsx
import Markdown from 'remix-markdown-katex'
import { Link } from '@remix-run/react'
import { InlineMath, BlockMath } from 'react-katex'
const MyLink = ({ children, ...props }) =>
props.href.startsWith('https://') || props.href.startsWith('http://') ? (
{children}
) : props.href.startsWith('/') ? (
{children}
) : (
{children}
)
const MySpan = ({ children, ...props }) =>
props.className === 'inline-math' ? (
) : props.className === 'block-math' ? (
) : (
{children}
)
const MyMarkdown = props => {
return (
options={{
disableParsingRawHTML: true,
overrides: {
a: {
component: MyLink,
},
span: {
component: MySpan,
},
},
}}
>
{props.children}
)
}
export default MyMarkdown
``