v7.4.0
Happy New Year! π
markdown-to-jsx v7.4 features a new option renderRule
! β From the README:
Supply your own rendering function that can selectively override how rules are rendered (note, this is different than options.overrides
which operates at the HTML tag level and is more general). You can use this functionality to do pretty much anything with an established AST node; here's an example of selectively overriding the "codeBlock" rule to process LaTeX syntax using the @matejmazur/react-katex
library:
import { Markdown, RuleType } from 'markdown-to-jsx'
import TeX from '@matejmazur/react-katex'
const exampleContent =
'Some important formula:\n\n```latex\nmathbb{N} = { a in mathbb{Z} : a > 0 }\n```\n'
function App() {
return (
<Markdown
children={exampleContent}
options={{
renderRule(next, node, renderChildren, state) {
if (node.type === RuleType.codeBlock && node.lang === 'latex') {
return (
<TeX as="div" key={state.key}>{String.raw`${node.text}`}</TeX>
)
}
return next()
},
}}
/>
)
}
The README docs around syntax highlighting have also been updated with sample code.
With the new year comes a push toward v8. Performance will be a top priority, reducing the complexity of the library's regexes to increase throughput for SSR use-cases and ideally eliminate rare but frustrating issues like catastrophic backtracking. In addition, the library will be pivoting into more of a pure compiler model, with a React adapter offered and ones added for other major frameworks as well. The idea is anywhere you can run JS, you can use [secret new library name].
Stay tuned and thanks for being part of the journey βπΌ
Here's to a great 2024 πΎ
markdown-to-jsx is maintained by @quantizor, buy him a coffee
Full Changelog: v7.3.2...v7.4.0