Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v8 development #559

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
5 changes: 5 additions & 0 deletions .changeset/dry-melons-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'markdown-to-jsx': major
---

Bump minimum React version to 16+. `markdown-to-jsx` can now return strings directly without needing a wrapper unless forced via `options.forceWrapper`.
5 changes: 5 additions & 0 deletions .changeset/five-frogs-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'markdown-to-jsx': minor
---

Add `options.enableRules` and `options.disableRules`; this allows for individual syntaxes to be conditionally switched on/off as desired.
5 changes: 5 additions & 0 deletions .changeset/sour-llamas-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'markdown-to-jsx': minor
---

Add `options.customRules`, this allows for novel functionality to be implemented in tandem with `options.renderRule`.
16 changes: 16 additions & 0 deletions .changeset/spicy-cherries-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'markdown-to-jsx': major
---

Introduce the `createMarkdown(options)` factory function. This factory wraps and replaces the prior `compiler(input, options)` top-level export, while also exposing the AST parser directly for ✨ advanced use cases ✨.

```tsx
import { createMarkdown } from 'markdown-to-jsx'

// parser = receive AST without going directly to React, allows for complete override
// compiler = parser + React output (the equivalent of using the `Markdown` component)
// Markdown = React component for convenience
const { Markdown, compiler, parser } = createMarkdown({
/* any options here */
})
```
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import cliProgress from 'cli-progress'
import * as fs from 'fs'
import SimpleMarkdown from 'simple-markdown'
import MarkdownIt from 'markdown-it'
import { compiler } from './dist/index.module.js'
import { createMarkdown } from './dist/index.module.js'

const mdIt = new MarkdownIt()
const suite = new BenchTable()
Expand All @@ -18,6 +18,8 @@ const bar = new cliProgress.SingleBar(
)
let totalCycles

const { compiler } = createMarkdown()

// add tests
suite
.addFunction('markdown-to-jsx', input => compiler(input))
Expand Down
9 changes: 6 additions & 3 deletions index.cjs.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Markdown, { compiler } from './'
Object.assign(Markdown, { compiler })
export default Markdown as typeof Markdown & { compiler: typeof compiler }
import Markdown, { createMarkdown } from './'

Object.assign(Markdown, { createMarkdown })
export default Markdown as typeof Markdown & {
createMarkdown: typeof createMarkdown
}