markdown-to-jsx 9.2.0 → 9.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -20
- package/dist/html.cjs +97 -96
- package/dist/html.d.cts +4 -2
- package/dist/html.d.ts +4 -2
- package/dist/html.js +97 -96
- package/dist/html.js.map +7 -7
- package/dist/index.cjs +85 -85
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +83 -83
- package/dist/index.js.map +7 -7
- package/dist/markdown.cjs +93 -93
- package/dist/markdown.js +93 -93
- package/dist/markdown.js.map +6 -6
- package/dist/native.cjs +100 -100
- package/dist/native.d.cts +3 -2
- package/dist/native.d.ts +3 -2
- package/dist/native.js +102 -102
- package/dist/native.js.map +7 -7
- package/dist/react.cjs +83 -83
- package/dist/react.d.cts +4 -8
- package/dist/react.d.ts +4 -8
- package/dist/react.js +85 -85
- package/dist/react.js.map +7 -7
- package/dist/solid.cjs +108 -0
- package/dist/solid.d.cts +373 -0
- package/dist/solid.d.ts +373 -0
- package/dist/solid.js +108 -0
- package/dist/solid.js.map +15 -0
- package/dist/vue.cjs +108 -0
- package/dist/vue.d.cts +373 -0
- package/dist/vue.d.ts +373 -0
- package/dist/vue.js +108 -0
- package/dist/vue.js.map +15 -0
- package/package.json +43 -4
package/README.md
CHANGED
|
@@ -26,6 +26,8 @@ Some special features of the library:
|
|
|
26
26
|
- [Main](#main)
|
|
27
27
|
- [React](#react)
|
|
28
28
|
- [React Native](#react-native)
|
|
29
|
+
- [SolidJS](#solidjs)
|
|
30
|
+
- [Vue.js](#vuejs)
|
|
29
31
|
- [HTML](#html)
|
|
30
32
|
- [Markdown](#markdown)
|
|
31
33
|
- [Library Options](#library-options)
|
|
@@ -272,6 +274,78 @@ HTML tags are automatically mapped to React Native components:
|
|
|
272
274
|
|
|
273
275
|
**Note:** Links are underlined by default for better accessibility and discoverability. You can override this via the `styles.link` option.
|
|
274
276
|
|
|
277
|
+
#### SolidJS
|
|
278
|
+
|
|
279
|
+
For SolidJS usage, import from the `/solid` entry point:
|
|
280
|
+
|
|
281
|
+
```tsx
|
|
282
|
+
import Markdown, {
|
|
283
|
+
compiler,
|
|
284
|
+
parser,
|
|
285
|
+
astToJSX,
|
|
286
|
+
MarkdownProvider,
|
|
287
|
+
} from 'markdown-to-jsx/solid'
|
|
288
|
+
import { createSignal } from 'solid-js'
|
|
289
|
+
|
|
290
|
+
// Static content
|
|
291
|
+
const solidElement = compiler('# Hello world')
|
|
292
|
+
|
|
293
|
+
function App() {
|
|
294
|
+
return <Markdown children="# Hello world" />
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Reactive content (automatically updates when content changes)
|
|
298
|
+
function ReactiveApp() {
|
|
299
|
+
const [content, setContent] = createSignal('# Hello world')
|
|
300
|
+
return <Markdown>{content}</Markdown>
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Or use parser + astToJSX
|
|
304
|
+
const ast = parser('# Hello world')
|
|
305
|
+
const solidElement2 = astToJSX(ast)
|
|
306
|
+
|
|
307
|
+
// Use context for default options
|
|
308
|
+
function AppWithContext() {
|
|
309
|
+
return (
|
|
310
|
+
<MarkdownProvider options={{ sanitizer: customSanitizer }}>
|
|
311
|
+
<Markdown># Content</Markdown>
|
|
312
|
+
</MarkdownProvider>
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**SolidJS-specific features:**
|
|
318
|
+
|
|
319
|
+
- **Reactive content**: The `Markdown` component accepts signals/accessors for automatic updates when markdown content changes
|
|
320
|
+
- **Memoization**: AST parsing is automatically memoized for optimal performance
|
|
321
|
+
- **Context API**: Use `MarkdownProvider` to provide default options and avoid prop drilling
|
|
322
|
+
|
|
323
|
+
#### Vue.js
|
|
324
|
+
|
|
325
|
+
For Vue.js 3 usage, import from the `/vue` entry point:
|
|
326
|
+
|
|
327
|
+
```tsx
|
|
328
|
+
import Markdown, { compiler, parser, astToJSX } from 'markdown-to-jsx/vue'
|
|
329
|
+
import { h } from 'vue'
|
|
330
|
+
|
|
331
|
+
// Using compiler
|
|
332
|
+
const vnode = compiler('# Hello world')
|
|
333
|
+
|
|
334
|
+
// Using component
|
|
335
|
+
<Markdown children="# Hello world" />
|
|
336
|
+
|
|
337
|
+
// Or use parser + astToJSX
|
|
338
|
+
const ast = parser('# Hello world')
|
|
339
|
+
const vnode2 = astToJSX(ast)
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Vue.js-specific features:**
|
|
343
|
+
|
|
344
|
+
- **Vue 3 support**: Uses Vue 3's `h()` render function API
|
|
345
|
+
- **JSX support**: Works with Vue 3 JSX via `@vue/babel-plugin-jsx` or `@vitejs/plugin-vue-jsx`
|
|
346
|
+
- **HTML attributes**: Uses standard HTML attributes (`class` instead of `className`)
|
|
347
|
+
- **Component overrides**: Support for both Options API and Composition API componen
|
|
348
|
+
|
|
275
349
|
#### HTML
|
|
276
350
|
|
|
277
351
|
For HTML string output (server-side rendering), import from the `/html` entry point:
|
|
@@ -304,23 +378,23 @@ const normalizedMarkdown2 = astToMarkdown(ast)
|
|
|
304
378
|
|
|
305
379
|
#### All Options
|
|
306
380
|
|
|
307
|
-
| Option | Type | Default | Description
|
|
308
|
-
| ----------------------- | ----------------------------- | -------- |
|
|
309
|
-
| `createElement` | `function` | - | Custom
|
|
310
|
-
| `disableAutoLink` | `boolean` | `false` | Disable automatic conversion of bare URLs to anchor tags.
|
|
311
|
-
| `disableParsingRawHTML` | `boolean` | `false` | Disable parsing of raw HTML into JSX.
|
|
312
|
-
| `enforceAtxHeadings` | `boolean` | `false` | Require space between `#` and header text (GFM spec compliance).
|
|
313
|
-
| `forceBlock` | `boolean` | `false` | Force all content to be treated as block-level.
|
|
314
|
-
| `forceInline` | `boolean` | `false` | Force all content to be treated as inline.
|
|
315
|
-
| `forceWrapper` | `boolean` | `false` | Force wrapper even with single child (React/React Native only). See [forceWrapper](#optionsforcewrapper) for details.
|
|
316
|
-
| `overrides` | `object` | - | Override HTML tag rendering. See [overrides](#optionsoverrides) for details.
|
|
317
|
-
| `preserveFrontmatter` | `boolean` | `false` | Include frontmatter in rendered output (as `<pre>` for HTML/JSX, included in markdown). Behavior varies by compiler type.
|
|
318
|
-
| `renderRule` | `function` | - | Custom rendering for AST rules. See [renderRule](#optionsrenderrule) for details.
|
|
319
|
-
| `sanitizer` | `function` | built-in | Custom URL sanitizer function. See [sanitizer](#optionssanitizer) for details.
|
|
320
|
-
| `slugify` | `function` | built-in | Custom slug generation for heading IDs. See [slugify](#optionsslugify) for details.
|
|
321
|
-
| `tagfilter` | `boolean` | `true` | Escape dangerous HTML tags (`script`, `iframe`, `style`, etc.) to prevent XSS.
|
|
322
|
-
| `wrapper` | `string \| component \| null` | `'div'` | Wrapper element for multiple children (React/React Native only). See [wrapper](#optionswrapper) for details.
|
|
323
|
-
| `wrapperProps` | `object` | - | Props for wrapper element (React/React Native only). See [wrapperProps](#optionswrapperprops) for details.
|
|
381
|
+
| Option | Type | Default | Description |
|
|
382
|
+
| ----------------------- | ----------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
383
|
+
| `createElement` | `function` | - | Custom createElement behavior (React/React Native/SolidJS/Vue only). See [createElement](#optionscreateelement) for details. |
|
|
384
|
+
| `disableAutoLink` | `boolean` | `false` | Disable automatic conversion of bare URLs to anchor tags. |
|
|
385
|
+
| `disableParsingRawHTML` | `boolean` | `false` | Disable parsing of raw HTML into JSX. |
|
|
386
|
+
| `enforceAtxHeadings` | `boolean` | `false` | Require space between `#` and header text (GFM spec compliance). |
|
|
387
|
+
| `forceBlock` | `boolean` | `false` | Force all content to be treated as block-level. |
|
|
388
|
+
| `forceInline` | `boolean` | `false` | Force all content to be treated as inline. |
|
|
389
|
+
| `forceWrapper` | `boolean` | `false` | Force wrapper even with single child (React/React Native/Vue only). See [forceWrapper](#optionsforcewrapper) for details. |
|
|
390
|
+
| `overrides` | `object` | - | Override HTML tag rendering. See [overrides](#optionsoverrides) for details. |
|
|
391
|
+
| `preserveFrontmatter` | `boolean` | `false` | Include frontmatter in rendered output (as `<pre>` for HTML/JSX, included in markdown). Behavior varies by compiler type. |
|
|
392
|
+
| `renderRule` | `function` | - | Custom rendering for AST rules. See [renderRule](#optionsrenderrule) for details. |
|
|
393
|
+
| `sanitizer` | `function` | built-in | Custom URL sanitizer function. See [sanitizer](#optionssanitizer) for details. |
|
|
394
|
+
| `slugify` | `function` | built-in | Custom slug generation for heading IDs. See [slugify](#optionsslugify) for details. |
|
|
395
|
+
| `tagfilter` | `boolean` | `true` | Escape dangerous HTML tags (`script`, `iframe`, `style`, etc.) to prevent XSS. |
|
|
396
|
+
| `wrapper` | `string \| component \| null` | `'div'` | Wrapper element for multiple children (React/React Native/Vue only). See [wrapper](#optionswrapper) for details. |
|
|
397
|
+
| `wrapperProps` | `object` | - | Props for wrapper element (React/React Native/Vue only). See [wrapperProps](#optionswrapperprops) for details. |
|
|
324
398
|
|
|
325
399
|
#### options.createElement
|
|
326
400
|
|
|
@@ -796,10 +870,9 @@ const Table = ({ columns, dataSource, ...props }) => {
|
|
|
796
870
|
<div>
|
|
797
871
|
```js
|
|
798
872
|
var code = here();
|
|
799
|
-
````
|
|
800
|
-
|
|
801
|
-
</div>
|
|
802
873
|
```
|
|
874
|
+
</div>
|
|
875
|
+
````
|
|
803
876
|
|
|
804
877
|
## Changelog
|
|
805
878
|
|