Skip to content

Commit

Permalink
refactor: adjust type documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
quantizor committed Jan 1, 2024
1 parent 34531eb commit 5b80921
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function App() {
<Markdown
children={exampleContent}
options={{
renderRule(next, node, renderAST, state) {
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>
Expand Down
2 changes: 1 addition & 1 deletion index.compiler.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3745,7 +3745,7 @@ describe('options.renderRule', () => {
it('should allow arbitrary modification of content', () => {
render(
compiler('Hello.\n\n```latex\n$$f(X,n) = X_n + X_{n-1}$$\n```\n', {
renderRule(defaultRenderer, node, output, state) {
renderRule(defaultRenderer, node, renderChildren, state) {
if (node.type === RuleType.codeBlock && node.lang === 'latex') {
return <div key={state.key}>I'm latex.</div>
}
Expand Down
7 changes: 5 additions & 2 deletions index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2267,7 +2267,7 @@ export namespace MarkdownToJSX {
* For example, to implement a LaTeX renderer such as `react-katex`:
*
* ```
* renderRule(next, node, output, state) {
* renderRule(next, node, renderChildren, state) {
* if (node.type === RuleType.codeBlock && node.lang === 'latex') {
* return (
* <TeX as="div" key={state.key}>
Expand All @@ -2287,8 +2287,11 @@ export namespace MarkdownToJSX {
renderRule: (
/** Resume normal processing, call this function as a fallback if you are not returning custom JSX. */
next: () => React.ReactChild,
/** the current AST node, use `RuleType` against `node.type` for identification */
node: ParserResult,
renderAST: RuleOutput,
/** use as `renderChildren(node.children)` for block nodes */
renderChildren: RuleOutput,
/** contains `key` which should be supplied to the topmost JSX element */
state: State
) => React.ReactChild

Expand Down
2 changes: 1 addition & 1 deletion site.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ const options = {
component: MyComponent,
},
},
renderRule(defaultOutput, node, renderAST, state) {
renderRule(defaultOutput, node, renderChildren, state) {
if (node.type === RuleType.codeBlock) {
if (node.lang === 'latex') {
return (
Expand Down

0 comments on commit 5b80921

Please sign in to comment.