markdown-to-jsx 7.0.1 → 7.1.3
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 +98 -50
- package/dist/index.cjs.d.ts +22 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -2,34 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
The most lightweight, customizable React markdown component.
|
|
4
4
|
|
|
5
|
-
[](https://badge.fury.io/js/markdown-to-jsx) <a href="https://bundlephobia.com/result?p=markdown-to-jsx" title="markdown-to-jsx latest minified+gzip size"><img src="https://badgen.net/bundlephobia/minzip/markdown-to-jsx" alt="gzip size"></a> [](https://travis-ci.org/probablyup/markdown-to-jsx) [](#backers) [](#sponsors)
|
|
5
|
+
[](https://badge.fury.io/js/markdown-to-jsx) <a href="https://bundlephobia.com/result?p=markdown-to-jsx" title="markdown-to-jsx latest minified+gzip size"><img src="https://badgen.net/bundlephobia/minzip/markdown-to-jsx" alt="gzip size"></a> [](https://travis-ci.org/probablyup/markdown-to-jsx) [](https://codecov.io/gh/probablyup/markdown-to-jsx) [](https://npm-stat.com/charts.html?package=markdown-to-jsx)
|
|
7
6
|
|
|
8
7
|
<!-- TOC -->
|
|
9
8
|
|
|
10
9
|
- [Installation](#installation)
|
|
11
10
|
- [Usage](#usage)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
11
|
+
- [Parsing Options](#parsing-options)
|
|
12
|
+
- [options.forceBlock](#optionsforceblock)
|
|
13
|
+
- [options.forceInline](#optionsforceinline)
|
|
14
|
+
- [options.wrapper](#optionswrapper)
|
|
15
|
+
- [Other useful recipes](#other-useful-recipes)
|
|
16
|
+
- [options.forceWrapper](#optionsforcewrapper)
|
|
17
|
+
- [options.overrides - Override Any HTML Tag's Representation](#optionsoverrides---override-any-html-tags-representation)
|
|
18
|
+
- [options.overrides - Rendering Arbitrary React Components](#optionsoverrides---rendering-arbitrary-react-components)
|
|
19
|
+
- [options.createElement - Custom React.createElement behavior](#optionscreateelement---custom-reactcreateelement-behavior)
|
|
20
|
+
- [options.slugify](#optionsslugify)
|
|
21
|
+
- [options.namedCodesToUnicode](#optionsnamedcodestounicode)
|
|
22
|
+
- [options.disableParsingRawHTML](#optionsdisableparsingrawhtml)
|
|
23
|
+
- [Syntax highlighting](#syntax-highlighting)
|
|
24
|
+
- [Getting the smallest possible bundle size](#getting-the-smallest-possible-bundle-size)
|
|
25
|
+
- [Usage with Preact](#usage-with-preact)
|
|
23
26
|
- [Gotchas](#gotchas)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- [Using The Compiler Directly](#using-the-compiler-directly)
|
|
27
|
+
- [Significant indentation inside arbitrary HTML](#significant-indentation-inside-arbitrary-html)
|
|
28
|
+
- [Code blocks](#code-blocks)
|
|
27
29
|
- [Changelog](#changelog)
|
|
28
30
|
- [Donate](#donate)
|
|
29
|
-
- [Credits](#credits)
|
|
30
|
-
- [Contributors](#contributors)
|
|
31
|
-
- [Backers](#backers)
|
|
32
|
-
- [Sponsors](#sponsors)
|
|
33
31
|
|
|
34
32
|
<!-- /TOC -->
|
|
35
33
|
|
|
@@ -127,6 +125,62 @@ compiler('# You got it babe!', { forceInline: true });
|
|
|
127
125
|
<span># You got it babe!</span>;
|
|
128
126
|
```
|
|
129
127
|
|
|
128
|
+
#### options.wrapper
|
|
129
|
+
|
|
130
|
+
When there are multiple children to be rendered, the compiler will wrap the output in a `div` by default. You can override this default by setting the `wrapper` option to either a string (React Element) or a component.
|
|
131
|
+
|
|
132
|
+
```jsx
|
|
133
|
+
const str = '# Heck Yes\n\nThis is great!'
|
|
134
|
+
|
|
135
|
+
<Markdown options={{ wrapper: 'article' }}>
|
|
136
|
+
{str}
|
|
137
|
+
</Markdown>;
|
|
138
|
+
|
|
139
|
+
// or
|
|
140
|
+
|
|
141
|
+
compiler(str, { wrapper: 'article' });
|
|
142
|
+
|
|
143
|
+
// renders
|
|
144
|
+
|
|
145
|
+
<article>
|
|
146
|
+
<h1>Heck Yes</h1>
|
|
147
|
+
<p>This is great!</p>
|
|
148
|
+
</article>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
##### Other useful recipes
|
|
152
|
+
|
|
153
|
+
To get an array of children back without a wrapper, set `wrapper` to `null`. This is particularly useful when using `compiler(…)` directly.
|
|
154
|
+
|
|
155
|
+
```jsx
|
|
156
|
+
compiler('One\n\nTwo\n\nThree', { wrapper: null });
|
|
157
|
+
|
|
158
|
+
// returns
|
|
159
|
+
|
|
160
|
+
[
|
|
161
|
+
(<p>One</p>),
|
|
162
|
+
(<p>Two</p>),
|
|
163
|
+
(<p>Three</p>)
|
|
164
|
+
]
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
To render children at the same DOM level as `<Markdown>` with no HTML wrapper, set `wrapper` to `React.Fragment`. This will still wrap your children in a React node for the purposes of rendering, but the wrapper element won't show up in the DOM.
|
|
168
|
+
|
|
169
|
+
#### options.forceWrapper
|
|
170
|
+
|
|
171
|
+
By default, the compiler does not wrap the rendered contents if there is only a single child. You can change this by setting `forceWrapper` to `true`. If the child is inline, it will not necessarily be wrapped in a `span`.
|
|
172
|
+
|
|
173
|
+
```jsx
|
|
174
|
+
// Using `forceWrapper` with a single, inline child…
|
|
175
|
+
<Markdown options={{ wrapper: 'aside', forceWrapper: true }}>
|
|
176
|
+
Mumble, mumble…
|
|
177
|
+
</Markdown>
|
|
178
|
+
|
|
179
|
+
// renders
|
|
180
|
+
|
|
181
|
+
<aside>Mumble, mumble…</aside>
|
|
182
|
+
```
|
|
183
|
+
|
|
130
184
|
#### options.overrides - Override Any HTML Tag's Representation
|
|
131
185
|
|
|
132
186
|
Pass the `options.overrides` prop to the compiler or `<Markdown>` component to seamlessly revise the rendered representation of any HTML tag. You can choose to change the component itself, add/change props, or both.
|
|
@@ -189,6 +243,12 @@ Depending on the type of element, there are some props that must be preserved to
|
|
|
189
243
|
|
|
190
244
|
Any conflicts between passed `props` and the specific properties above will be resolved in favor of `markdown-to-jsx`'s code.
|
|
191
245
|
|
|
246
|
+
Some element mappings are a bit different from other libraries, in particular:
|
|
247
|
+
|
|
248
|
+
- `span`: Used for inline text.
|
|
249
|
+
- `code`: Used for inline code.
|
|
250
|
+
- `pre > code`: Code blocks are a `code` element with a `pre` as its direct ancestor.
|
|
251
|
+
|
|
192
252
|
#### options.overrides - Rendering Arbitrary React Components
|
|
193
253
|
|
|
194
254
|
One of the most interesting use cases enabled by the HTML syntax processing in `markdown-to-jsx` is the ability to use any kind of element, even ones that aren't real HTML tags like React component classes.
|
|
@@ -265,7 +325,7 @@ render(
|
|
|
265
325
|
);
|
|
266
326
|
```
|
|
267
327
|
|
|
268
|
-
Another possibility is to use something like [recompose's `withProps()` HOC](https://github.com/acdlite/recompose/blob/
|
|
328
|
+
Another possibility is to use something like [recompose's `withProps()` HOC](https://github.com/acdlite/recompose/blob/main/docs/API.md#withprops) to create various pregenerated scenarios and then reference them by name in the markdown:
|
|
269
329
|
|
|
270
330
|
```jsx
|
|
271
331
|
import Markdown from 'markdown-to-jsx';
|
|
@@ -409,6 +469,22 @@ compiler('This text has <span>html</span> in it but it won't be rendered', { dis
|
|
|
409
469
|
<span>This text has <span>html</span> in it but it won't be rendered</span>
|
|
410
470
|
```
|
|
411
471
|
|
|
472
|
+
### Syntax highlighting
|
|
473
|
+
|
|
474
|
+
Some syntax highlighters require you to specify the language. The language of the code fence is
|
|
475
|
+
forwarded in the className prop of the element used for `<code>`:
|
|
476
|
+
|
|
477
|
+
```jsx
|
|
478
|
+
const Code = ({className, children}) => {
|
|
479
|
+
const language = className.replace("lang-", "");
|
|
480
|
+
|
|
481
|
+
return (
|
|
482
|
+
<SyntaxHighlighter language={language}>
|
|
483
|
+
<code>{children}</code>
|
|
484
|
+
</SyntaxHighlighter>
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
```
|
|
412
488
|
### Getting the smallest possible bundle size
|
|
413
489
|
|
|
414
490
|
Many development conveniences are placed behind `process.env.NODE_ENV !== "production"` conditionals. When bundling your app, it's a good idea to replace these code snippets such that a minifier (like uglify) can sweep them away and leave a smaller overall bundle.
|
|
@@ -502,34 +578,6 @@ See [Github Releases](https://github.com/probablyup/markdown-to-jsx/releases).
|
|
|
502
578
|
|
|
503
579
|
## Donate
|
|
504
580
|
|
|
505
|
-
Like this library? It's developed entirely on a volunteer basis; chip in a few bucks if you can at
|
|
506
|
-
|
|
507
|
-
## Credits
|
|
508
|
-
|
|
509
|
-
### Contributors
|
|
510
|
-
|
|
511
|
-
This project exists thanks to all the people who contribute.
|
|
512
|
-
<a href="https://github.com/probablyup/markdown-to-jsx/graphs/contributors"><img src="https://opencollective.com/markdown-to-jsx/contributors.svg?width=890&button=false" /></a>
|
|
513
|
-
|
|
514
|
-
### Backers
|
|
515
|
-
|
|
516
|
-
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/markdown-to-jsx#backer)]
|
|
517
|
-
|
|
518
|
-
<a href="https://opencollective.com/markdown-to-jsx#backers" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/backers.svg?width=890"></a>
|
|
519
|
-
|
|
520
|
-
### Sponsors
|
|
521
|
-
|
|
522
|
-
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/markdown-to-jsx#sponsor)]
|
|
523
|
-
|
|
524
|
-
<a href="https://opencollective.com/markdown-to-jsx/sponsor/0/website" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/sponsor/0/avatar.svg"></a>
|
|
525
|
-
<a href="https://opencollective.com/markdown-to-jsx/sponsor/1/website" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/sponsor/1/avatar.svg"></a>
|
|
526
|
-
<a href="https://opencollective.com/markdown-to-jsx/sponsor/2/website" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/sponsor/2/avatar.svg"></a>
|
|
527
|
-
<a href="https://opencollective.com/markdown-to-jsx/sponsor/3/website" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/sponsor/3/avatar.svg"></a>
|
|
528
|
-
<a href="https://opencollective.com/markdown-to-jsx/sponsor/4/website" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/sponsor/4/avatar.svg"></a>
|
|
529
|
-
<a href="https://opencollective.com/markdown-to-jsx/sponsor/5/website" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/sponsor/5/avatar.svg"></a>
|
|
530
|
-
<a href="https://opencollective.com/markdown-to-jsx/sponsor/6/website" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/sponsor/6/avatar.svg"></a>
|
|
531
|
-
<a href="https://opencollective.com/markdown-to-jsx/sponsor/7/website" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/sponsor/7/avatar.svg"></a>
|
|
532
|
-
<a href="https://opencollective.com/markdown-to-jsx/sponsor/8/website" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/sponsor/8/avatar.svg"></a>
|
|
533
|
-
<a href="https://opencollective.com/markdown-to-jsx/sponsor/9/website" target="_blank"><img src="https://opencollective.com/markdown-to-jsx/sponsor/9/avatar.svg"></a>
|
|
581
|
+
Like this library? It's developed entirely on a volunteer basis; chip in a few bucks if you can at my [Patreon](https://www.patreon.com/bePatron?u=27436864).
|
|
534
582
|
|
|
535
583
|
MIT
|
package/dist/index.cjs.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { compiler } from './';
|
|
3
|
+
declare const _default: import("react").FC<{
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
children: string;
|
|
6
|
+
options?: Partial<{
|
|
7
|
+
createElement: (tag: string | import("react").FunctionComponent<{}> | import("react").ComponentClass<{}, any>, props: import("react").Props<any>, ...children: import("react").ReactChild[]) => JSX.Element;
|
|
8
|
+
disableParsingRawHTML: boolean;
|
|
9
|
+
forceBlock: boolean;
|
|
10
|
+
forceInline: boolean;
|
|
11
|
+
namedCodesToUnicode: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
overrides: import("./").MarkdownToJSX.Overrides;
|
|
15
|
+
wrapper: import("react").ElementType<any>;
|
|
16
|
+
forceWrapper: boolean;
|
|
17
|
+
slugify: (source: string) => string;
|
|
18
|
+
}>;
|
|
19
|
+
}> & {
|
|
20
|
+
compiler: typeof compiler;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare namespace MarkdownToJSX {
|
|
|
17
17
|
_list?: boolean;
|
|
18
18
|
inline?: boolean;
|
|
19
19
|
inTable?: boolean;
|
|
20
|
+
inAnchor?: boolean;
|
|
20
21
|
key?: React.Key;
|
|
21
22
|
simple?: boolean;
|
|
22
23
|
};
|
|
@@ -37,9 +38,9 @@ export declare namespace MarkdownToJSX {
|
|
|
37
38
|
[key: string]: Rule;
|
|
38
39
|
};
|
|
39
40
|
export type Override = RequireAtLeastOne<{
|
|
40
|
-
component: React.
|
|
41
|
+
component: React.ElementType;
|
|
41
42
|
props: Object;
|
|
42
|
-
}> | React.
|
|
43
|
+
}> | React.ElementType;
|
|
43
44
|
export type Overrides = {
|
|
44
45
|
[tag in HTMLTags]?: Override;
|
|
45
46
|
} & {
|
|
@@ -91,6 +92,18 @@ export declare namespace MarkdownToJSX {
|
|
|
91
92
|
* emitted by the compiler.
|
|
92
93
|
*/
|
|
93
94
|
overrides: Overrides;
|
|
95
|
+
/**
|
|
96
|
+
* Declare the type of the wrapper to be used when there are multiple
|
|
97
|
+
* children to render. Set to `null` to get an array of children back
|
|
98
|
+
* without any wrapper, or use `React.Fragment` to get a React element
|
|
99
|
+
* that won't show up in the DOM.
|
|
100
|
+
*/
|
|
101
|
+
wrapper: React.ElementType | null;
|
|
102
|
+
/**
|
|
103
|
+
* Forces the compiler to wrap results, even if there is only a single
|
|
104
|
+
* child or no children.
|
|
105
|
+
*/
|
|
106
|
+
forceWrapper: boolean;
|
|
94
107
|
/**
|
|
95
108
|
* Override normalization of non-URI-safe characters for use in generating
|
|
96
109
|
* HTML IDs for anchor linking purposes.
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e,t=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e;function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?r(Object(a),!0).forEach(function(t){n(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):r(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}var c=/[\'\"]/,o={accesskey:"accessKey",allowfullscreen:"allowFullScreen",allowtransparency:"allowTransparency",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",classid:"classId",colspan:"colSpan",contenteditable:"contentEditable",contextmenu:"contextMenu",crossorigin:"crossOrigin",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},i={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:"“"},l=["style","script"],u=/([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi,s=/mailto:/i,f=/\n{2,}$/,p=/^( *>[^\n]+(\n[^\n]+)*\n*)+\n{2,}/,d=/^ *> ?/gm,g=/^ {2,}\n/,m=/^(?:( *[-*_]) *){3,}(?:\n *)+\n/,y=/^\s*(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n *)+\n?/,h=/^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/,k=/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,v=/^(?:\n *)*\n/,b=/\r\n?/g,x=/^\[\^([^\]]+)](:.*)\n/,O=/^\[\^([^\]]+)]/,H=/\f/g,S=/^\s*?\[(x|\s)\]/,w=/^ *(#{1,6}) *([^\n]+)\n{0,2}/,I=/^([^\n]+)\n *(=|-){3,} *(?:\n *)+\n/,A=/^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?([^>]*)\/{0}>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1)[\s\S])*?)<\/\1>\n*/i,M=/&([a-z]+);/g,j=/^<!--.*?-->/,E=/^(data|aria|x)-[a-z_][a-z\d_.-]*$/,C=/^ *<([a-z][a-z0-9:]*)(?:\s+((?:<.*?>|[^>])*))?\/?>(?!<\/\1>)(\s*\n)?/i,G=/^\{.*\}$/,L=/^(https?:\/\/[^\s<]+[^<.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s*\\n*$)"),se="(?:\\[[^\\]]*\\]|[^\\[\\]]|\\](?=[^\\[]*\\]))*",fe=new RegExp("^\\[("+se+")\\]\\(\\s*<?((?:[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)"),pe=new RegExp("^!\\[("+se+")\\]\\(\\s*<?((?:[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)"),de=[p,h,y,w,I,A,j,C,le,ue,D,R];function ge(e){return e.replace(/[ÀÁÂÃÄÅàáâãä忯]/g,"a").replace(/[çÇ]/g,"c").replace(/[ðÐ]/g,"d").replace(/[ÈÉÊËéèêë]/g,"e").replace(/[ÏïÎîÍíÌì]/g,"i").replace(/[Ññ]/g,"n").replace(/[øØœŒÕõÔôÓóÒò]/g,"o").replace(/[ÜüÛûÚúÙù]/g,"u").replace(/[ŸÿÝý]/g,"y").replace(/[^a-z0-9- ]/gi,"").replace(/ /gi,"-").toLowerCase()}function me(e){return J.test(e)?"right":K.test(e)?"center":Q.test(e)?"left":null}function ye(e,t,n){var r=n.inTable;n.inTable=!0;var a=t(e.trim(),n);n.inTable=r;var c=[[]];return a.forEach(function(e,t){"tableSeparator"===e.type?0!==t&&t!==a.length-1&&c.push([]):("text"!==e.type||null!=a[t+1]&&"tableSeparator"!==a[t+1].type||(e.content=e.content.replace(V,"")),c[c.length-1].push(e))}),c}function he(e,t,n){n.inline=!0;var r=ye(e[1],t,n),a=e[2].replace(q,"").split("|").map(me),c=function(e,t,n){return e.trim().split("\n").map(function(e){return ye(e,t,n)})}(e[3],t,n);return n.inline=!1,{align:a,cells:c,header:r,type:"table"}}function ke(e,t){return null==e.align[t]?{}:{textAlign:e.align[t]}}function ve(e){return function(t,n){return n.inline?e.exec(t):null}}function be(e){return function(t,n){return n.inline||n.simple?e.exec(t):null}}function xe(e){return function(t,n){return n.inline||n.simple?null:e.exec(t)}}function Oe(e){return function(t){return e.exec(t)}}function He(e){try{if(decodeURIComponent(e).replace(/[^A-Za-z0-9/:]/g,"").match(/^\s*(javascript|vbscript|data):/i))return null}catch(e){return null}return e}function Se(e){return e.replace(oe,"$1")}function we(e,t,n){var r=n.inline||!1,a=n.simple||!1;n.inline=!0,n.simple=!0;var c=e(t,n);return n.inline=r,n.simple=a,c}function Ie(e,t,n){var r=n.inline||!1,a=n.simple||!1;n.inline=!1,n.simple=!0;var c=e(t,n);return n.inline=r,n.simple=a,c}function Ae(e,t,n){return n.inline=!1,e(t+"\n\n",n)}var Me,je=function(e,t,n){return{content:we(t,e[1],n)}};function Ee(){return{}}function Ce(){return null}function Ge(){return[].slice.call(arguments).filter(Boolean).join(" ")}function Le(e,t,n){for(var r=e,a=t.split(".");a.length&&void 0!==(r=r[a[0]]);)a.shift();return r||n}function $e(e,t){var n=Le(t,e);return n?"function"==typeof n||"object"==typeof n&&"render"in n?n:Le(t,e+".component",e):e}function Te(e,n){void 0===n&&(n={}),n.overrides=n.overrides||{},n.slugify=n.slugify||ge,n.namedCodesToUnicode=n.namedCodesToUnicode?a(a({},i),n.namedCodesToUnicode):i;var r=n.createElement||t.createElement;function q(e,t){var c=Le(n.overrides,e+".props",{});return r.apply(void 0,[$e(e,n.overrides),a(a(a({},t),c),{},{className:Ge(null==t?void 0:t.className,c.className)||void 0})].concat([].slice.call(arguments,2)))}function V(e){var t=!1;n.forceInline?t=!0:n.forceBlock||(t=!1===W.test(e));var r,a=ye(me(t?e:e.replace(ae,"")+"\n\n",{inline:t}));return a.length>1?r=q(t?"span":"div",{key:"outer"},a):1===a.length?"string"==typeof(r=a[0])&&(r=q("span",{key:"outer"},r)):r=q("span",{key:"outer"}),r}function K(e){var n=e.match(u);return n?n.reduce(function(e,n,r){var a=n.indexOf("=");if(-1!==a){var i=function(e){return-1!==e.indexOf("-")&&null===e.match(E)&&(e=e.replace(X,function(e,t){return t.toUpperCase()})),e}(n.slice(0,a)).trim(),l=function(e){return e?(c.test(e.charAt(0))&&(e=e.substr(1)),c.test(e.charAt(e.length-1))&&(e=e.substr(0,e.length-1)),e):""}(n.slice(a+1).trim()),u=o[i]||i,s=e[u]=function(e,t){return"style"===e?t.split(/;\s?/).reduce(function(e,t){var n=t.slice(0,t.indexOf(":"));return e[n.replace(/(-[a-z])/g,function(e){return e[1].toUpperCase()})]=t.slice(n.length+1).trim(),e},{}):"href"===e?He(t):(t.match(G)&&(t=t.slice(1,t.length-1)),"true"===t||"false"!==t&&t)}(i,l);"string"==typeof s&&(A.test(s)||C.test(s))&&(e[u]=t.cloneElement(V(s.trim()),{key:r}))}else"style"!==n&&(e[o[n]||n]=!0);return e},{}):void 0}var Q=[],J={},oe={blockQuote:{match:xe(p),order:Me.HIGH,parse:function(e,t,n){return{content:t(e[0].replace(d,""),n)}},react:function(e,t,n){return q("blockquote",{key:n.key},t(e.content,n))}},breakLine:{match:Oe(g),order:Me.HIGH,parse:Ee,react:function(e,t,n){return q("br",{key:n.key})}},breakThematic:{match:xe(m),order:Me.HIGH,parse:Ee,react:function(e,t,n){return q("hr",{key:n.key})}},codeBlock:{match:xe(h),order:Me.MAX,parse:function(e){return{content:e[0].replace(/^ {4}/gm,"").replace(/\n+$/,""),lang:void 0}},react:function(e,t,n){return q("pre",{key:n.key},q("code",{className:e.lang?"lang-"+e.lang:""},e.content))}},codeFenced:{match:xe(y),order:Me.MAX,parse:function(e){return{content:e[3],lang:e[2]||void 0,type:"codeBlock"}}},codeInline:{match:be(k),order:Me.LOW,parse:function(e){return{content:e[2]}},react:function(e,t,n){return q("code",{key:n.key},e.content)}},footnote:{match:xe(x),order:Me.MAX,parse:function(e){return Q.push({footnote:e[2],identifier:e[1]}),{}},react:Ce},footnoteReference:{match:ve(O),order:Me.HIGH,parse:function(e){return{content:e[1],target:"#"+n.slugify(e[1])}},react:function(e,t,n){return q("a",{key:n.key,href:He(e.target)},q("sup",{key:n.key},e.content))}},gfmTask:{match:ve(S),order:Me.HIGH,parse:function(e){return{completed:"x"===e[1].toLowerCase()}},react:function(e,t,n){return q("input",{checked:e.completed,key:n.key,readOnly:!0,type:"checkbox"})}},heading:{match:xe(w),order:Me.HIGH,parse:function(e,t,r){return{content:we(t,e[2],r),id:n.slugify(e[2]),level:e[1].length}},react:function(e,t,n){return e.tag="h"+e.level,q(e.tag,{id:e.id,key:n.key},t(e.content,n))}},headingSetext:{match:xe(I),order:Me.MAX,parse:function(e,t,n){return{content:we(t,e[1],n),level:"="===e[2]?1:2,type:"heading"}}},htmlComment:{match:Oe(j),order:Me.HIGH,parse:function(){return{}},react:Ce},image:{match:be(pe),order:Me.HIGH,parse:function(e){return{alt:e[1],target:Se(e[2]),title:e[3]}},react:function(e,t,n){return q("img",{key:n.key,alt:e.alt||void 0,title:e.title||void 0,src:He(e.target)})}},link:{match:ve(fe),order:Me.LOW,parse:function(e,t,n){return{content:Ie(t,e[1],n),target:Se(e[2]),title:e[3]}},react:function(e,t,n){return q("a",{key:n.key,href:He(e.target),title:e.title},t(e.content,n))}},linkAngleBraceStyleDetector:{match:ve(T),order:Me.MAX,parse:function(e){return{content:[{content:e[1],type:"text"}],target:e[1],type:"link"}}},linkBareUrlDetector:{match:ve(L),order:Me.MAX,parse:function(e){return{content:[{content:e[1],type:"text"}],target:e[1],title:void 0,type:"link"}}},linkMailtoDetector:{match:ve($),order:Me.MAX,parse:function(e){var t=e[1],n=e[1];return s.test(n)||(n="mailto:"+n),{content:[{content:t.replace("mailto:",""),type:"text"}],target:n,type:"link"}}},list:{match:function(e,t,n){var r=z.exec(n);return!r||!t._list&&t.inline?null:ue.exec(e=r[1]+e)},order:Me.HIGH,parse:function(e,t,n){var r=e[2],a=r.length>1,c=a?+r:void 0,o=e[0].replace(f,"\n").match(le),i=!1;return{items:o.map(function(e,r){var a=ie.exec(e)[0].length,c=new RegExp("^ {1,"+a+"}","gm"),l=e.replace(c,"").replace(ie,""),u=r===o.length-1,s=-1!==l.indexOf("\n\n")||u&&i;i=s;var f,p=n.inline,d=n._list;n._list=!0,s?(n.inline=!1,f=l.replace(P,"\n\n")):(n.inline=!0,f=l.replace(P,""));var g=t(f,n);return n.inline=p,n._list=d,g}),ordered:a,start:c}},react:function(e,t,n){return q(e.ordered?"ol":"ul",{key:n.key,start:e.start},e.items.map(function(e,r){return q("li",{key:r},t(e,n))}))}},newlineCoalescer:{match:xe(v),order:Me.LOW,parse:Ee,react:function(){return"\n"}},paragraph:{match:xe(R),order:Me.LOW,parse:je,react:function(e,t,n){return q("p",{key:n.key},t(e.content,n))}},ref:{match:ve(_),order:Me.MAX,parse:function(e){return J[e[1]]={target:e[2],title:e[4]},{}},react:Ce},refImage:{match:be(B),order:Me.MAX,parse:function(e){return{alt:e[1]||void 0,ref:e[2]}},react:function(e,t,n){return q("img",{key:n.key,alt:e.alt,src:He(J[e.ref].target),title:J[e.ref].title})}},refLink:{match:ve(N),order:Me.MAX,parse:function(e,t,n){return{content:t(e[1],n),fallbackContent:t(e[0].replace(U,"\\$1"),n),ref:e[2]}},react:function(e,t,n){return J[e.ref]?q("a",{key:n.key,href:He(J[e.ref].target),title:J[e.ref].title},t(e.content,n)):q("span",{key:n.key},t(e.fallbackContent,n))}},table:{match:xe(D),order:Me.HIGH,parse:he,react:function(e,t,n){return q("table",{key:n.key},q("thead",null,q("tr",null,e.header.map(function(r,a){return q("th",{key:a,style:ke(e,a)},t(r,n))}))),q("tbody",null,e.cells.map(function(r,a){return q("tr",{key:a},r.map(function(r,a){return q("td",{key:a,style:ke(e,a)},t(r,n))}))})))}},tableSeparator:{match:function(e,t){return t.inTable?F.exec(e):null},order:Me.HIGH,parse:function(){return{type:"tableSeparator"}},react:function(){return" | "}},text:{match:Oe(re),order:Me.MIN,parse:function(e){return{content:e[0].replace(M,function(e,t){return n.namedCodesToUnicode[t]?n.namedCodesToUnicode[t]:e})}},react:function(e){return e.content}},textBolded:{match:be(Y),order:Me.MED,parse:function(e,t,n){return{content:t(e[2],n)}},react:function(e,t,n){return q("strong",{key:n.key},t(e.content,n))}},textEmphasized:{match:be(ee),order:Me.LOW,parse:function(e,t,n){return{content:t(e[2],n)}},react:function(e,t,n){return q("em",{key:n.key},t(e.content,n))}},textEscaped:{match:be(ne),order:Me.HIGH,parse:function(e){return{content:e[1],type:"text"}}},textStrikethroughed:{match:be(te),order:Me.LOW,parse:je,react:function(e,t,n){return q("del",{key:n.key},t(e.content,n))}}};!0!==n.disableParsingRawHTML&&(oe.htmlBlock={match:Oe(A),order:Me.HIGH,parse:function(e,t,n){var r,a=e[3].match(ce),c=new RegExp("^"+a[1],"gm"),o=e[3].replace(c,""),i=(r=o,de.some(function(e){return e.test(r)})?Ae:we),u=e[1].toLowerCase(),s=-1!==l.indexOf(u);return{attrs:K(e[2]),content:s?e[3]:i(t,o,n),noInnerParse:s,tag:s?u:e[1]}},react:function(e,t,n){return q(e.tag,Object.assign({key:n.key},e.attrs),e.noInnerParse?e.content:t(e.content,n))}},oe.htmlSelfClosing={match:Oe(C),order:Me.HIGH,parse:function(e){return{attrs:K(e[2]||""),tag:e[1]}},react:function(e,t,n){return q(e.tag,Object.assign({},e.attrs,{key:n.key}))}});var se,me=function(e){var t=Object.keys(e);function n(r,a){for(var c=[],o="";r;)for(var i=0;i<t.length;){var l=t[i],u=e[l],s=u.match(r,a,o);if(s){var f=s[0];r=r.substring(f.length);var p=u.parse(s,n,a);null==p.type&&(p.type=l),c.push(p),o=f;break}i++}return c}return t.sort(function(t,n){var r=e[t].order,a=e[n].order;return r!==a?r-a:t<n?-1:1}),function(e,t){return n(function(e){return e.replace(b,"\n").replace(H,"").replace(Z," ")}(e),t)}}(oe),ye=(se=function(e){return function(t,n,r){return e[t.type].react(t,n,r)}}(oe),function e(t,n){if(void 0===n&&(n={}),Array.isArray(t)){for(var r=n.key,a=[],c=!1,o=0;o<t.length;o++){n.key=o;var i=e(t[o],n),l="string"==typeof i;l&&c?a[a.length-1]+=i:a.push(i),c=l}return n.key=r,a}return se(t,e,n)}),Te=V(e.replace(/<!--[\s\S]*?(?:-->)/g,""));return Q.length&&Te.props.children.push(q("footer",{key:"footer"},Q.map(function(e){return q("div",{id:n.slugify(e.identifier),key:e.identifier},e.identifier,ye(me(e.footnote,{inline:!0})))}))),Te}!function(e){e[e.MAX=0]="MAX",e[e.HIGH=1]="HIGH",e[e.MED=2]="MED",e[e.LOW=3]="LOW",e[e.MIN=4]="MIN"}(Me||(Me={}));var Pe=function(e){var n=e.children,r=e.options,a=function(e,t){if(null==e)return{};var n,r,a={},c=Object.keys(e);for(r=0;r<c.length;r++)t.indexOf(n=c[r])>=0||(a[n]=e[n]);return a}(e,["children","options"]);return t.cloneElement(Te(n,r),a)};Object.assign(Pe,{compiler:Te}),module.exports=Pe;
|
|
1
|
+
function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=e(require("react"));function t(){return(t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var r=/[\'\"]/,a={accesskey:"accessKey",allowfullscreen:"allowFullScreen",allowtransparency:"allowTransparency",autocomplete:"autoComplete",autofocus:"autoFocus",autoplay:"autoPlay",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",classid:"classId",colspan:"colSpan",contenteditable:"contentEditable",contextmenu:"contextMenu",crossorigin:"crossOrigin",enctype:"encType",for:"htmlFor",formaction:"formAction",formenctype:"formEncType",formmethod:"formMethod",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",inputmode:"inputMode",keyparams:"keyParams",keytype:"keyType",marginheight:"marginHeight",marginwidth:"marginWidth",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",novalidate:"noValidate",radiogroup:"radioGroup",readonly:"readOnly",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"},c={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:"“"},o=["style","script"],i=/([-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\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)"),fe=[s,g,m,A,I,S,w,E,oe,ie,j,R];function pe(e){return e.replace(/[ÀÁÂÃÄÅàáâãä忯]/g,"a").replace(/[çÇ]/g,"c").replace(/[ðÐ]/g,"d").replace(/[ÈÉÊËéèêë]/g,"e").replace(/[ÏïÎîÍíÌì]/g,"i").replace(/[Ññ]/g,"n").replace(/[øØœŒÕõÔôÓóÒò]/g,"o").replace(/[ÜüÛûÚúÙù]/g,"u").replace(/[ŸÿÝý]/g,"y").replace(/[^a-z0-9- ]/gi,"").replace(/ /gi,"-").toLowerCase()}function de(e){return K.test(e)?"right":q.test(e)?"center":V.test(e)?"left":null}function me(e,n,t){var r=t.inTable;t.inTable=!0;var a=n(e.trim(),t);t.inTable=r;var c=[[]];return a.forEach(function(e,n){"tableSeparator"===e.type?0!==n&&n!==a.length-1&&c.push([]):("text"!==e.type||null!=a[n+1]&&"tableSeparator"!==a[n+1].type||(e.content=e.content.replace(F,"")),c[c.length-1].push(e))}),c}function ge(e,n,t){t.inline=!0;var r=me(e[1],n,t),a=e[2].replace(Z,"").split("|").map(de),c=function(e,n,t){return e.trim().split("\n").map(function(e){return me(e,n,t)})}(e[3],n,t);return t.inline=!1,{align:a,cells:c,header:r,type:"table"}}function he(e,n){return null==e.align[n]?{}:{textAlign:e.align[n]}}function ye(e){return function(n,t){return t.inline?e.exec(n):null}}function ke(e){return function(n,t){return t.inline||t.simple?e.exec(n):null}}function ve(e){return function(n,t){return t.inline||t.simple?null:e.exec(n)}}function xe(e){return function(n){return e.exec(n)}}function be(e){try{if(decodeURIComponent(e).replace(/[^A-Za-z0-9/:]/g,"").match(/^\s*(javascript|vbscript|data):/i))return null}catch(e){return null}return e}function He(e){return e.replace(ae,"$1")}function Ae(e,n,t){var r=t.inline||!1,a=t.simple||!1;t.inline=!0,t.simple=!0;var c=e(n,t);return t.inline=r,t.simple=a,c}function Ie(e,n,t){var r=t.inline||!1,a=t.simple||!1;t.inline=!1,t.simple=!0;var c=e(n,t);return t.inline=r,t.simple=a,c}function Se(e,n,t){return t.inline=!1,e(n+"\n\n",t)}var Oe,we=function(e,n,t){return{content:Ae(n,e[1],t)}};function Me(){return{}}function Ee(){return null}function $e(){return[].slice.call(arguments).filter(Boolean).join(" ")}function Ce(e,n,t){for(var r=e,a=n.split(".");a.length&&void 0!==(r=r[a[0]]);)a.shift();return r||t}function Ge(e,n){var t=Ce(n,e);return t?"function"==typeof t||"object"==typeof t&&"render"in t?t:Ce(n,e+".component",e):e}function Le(e,Z){void 0===Z&&(Z={}),Z.overrides=Z.overrides||{},Z.slugify=Z.slugify||pe,Z.namedCodesToUnicode=Z.namedCodesToUnicode?t({},c,Z.namedCodesToUnicode):c;var F=Z.createElement||n.default.createElement;function q(e,n){var r=Ce(Z.overrides,e+".props",{});return F.apply(void 0,[Ge(e,Z.overrides),t({},n,r,{className:$e(null==n?void 0:n.className,r.className)||void 0})].concat([].slice.call(arguments,2)))}function V(e){var t=!1;Z.forceInline?t=!0:Z.forceBlock||(t=!1===U.test(e));var r=Te(Le(t?e:e.replace(te,"")+"\n\n",{inline:t}));if(null===Z.wrapper)return r;var a,c=Z.wrapper||(t?"span":"div");if(r.length>1||Z.forceWrapper)a=r;else{if(1===r.length)return"string"==typeof(a=r[0])?q("span",{key:"outer"},a):a;a=null}return n.default.createElement(c,{key:"outer"},a)}function K(e){var t=e.match(i);return t?t.reduce(function(e,t,c){var o=t.indexOf("=");if(-1!==o){var i=function(e){return-1!==e.indexOf("-")&&null===e.match(M)&&(e=e.replace(X,function(e,n){return n.toUpperCase()})),e}(t.slice(0,o)).trim(),l=function(e){return e?(r.test(e.charAt(0))&&(e=e.substr(1)),r.test(e.charAt(e.length-1))&&(e=e.substr(0,e.length-1)),e):""}(t.slice(o+1).trim()),u=a[i]||i,s=e[u]=function(e,n){return"style"===e?n.split(/;\s?/).reduce(function(e,n){var t=n.slice(0,n.indexOf(":"));return e[t.replace(/(-[a-z])/g,function(e){return e[1].toUpperCase()})]=n.slice(t.length+1).trim(),e},{}):"href"===e?be(n):(n.match($)&&(n=n.slice(1,n.length-1)),"true"===n||"false"!==n&&n)}(i,l);"string"==typeof s&&(S.test(s)||E.test(s))&&(e[u]=n.default.cloneElement(V(s.trim()),{key:c}))}else"style"!==t&&(e[a[t]||t]=!0);return e},{}):void 0}var ae=[],le={},de={blockQuote:{match:ve(s),order:Oe.HIGH,parse:function(e,n,t){return{content:n(e[0].replace(f,""),t)}},react:function(e,n,t){return q("blockquote",{key:t.key},n(e.content,t))}},breakLine:{match:xe(p),order:Oe.HIGH,parse:Me,react:function(e,n,t){return q("br",{key:t.key})}},breakThematic:{match:ve(d),order:Oe.HIGH,parse:Me,react:function(e,n,t){return q("hr",{key:t.key})}},codeBlock:{match:ve(g),order:Oe.MAX,parse:function(e){return{content:e[0].replace(/^ {4}/gm,"").replace(/\n+$/,""),lang:void 0}},react:function(e,n,t){return q("pre",{key:t.key},q("code",{className:e.lang?"lang-"+e.lang:""},e.content))}},codeFenced:{match:ve(m),order:Oe.MAX,parse:function(e){return{content:e[3],lang:e[2]||void 0,type:"codeBlock"}}},codeInline:{match:ke(h),order:Oe.LOW,parse:function(e){return{content:e[2]}},react:function(e,n,t){return q("code",{key:t.key},e.content)}},footnote:{match:ve(v),order:Oe.MAX,parse:function(e){return ae.push({footnote:e[2],identifier:e[1]}),{}},react:Ee},footnoteReference:{match:ye(x),order:Oe.HIGH,parse:function(e){return{content:e[1],target:"#"+Z.slugify(e[1])}},react:function(e,n,t){return q("a",{key:t.key,href:be(e.target)},q("sup",{key:t.key},e.content))}},gfmTask:{match:ye(H),order:Oe.HIGH,parse:function(e){return{completed:"x"===e[1].toLowerCase()}},react:function(e,n,t){return q("input",{checked:e.completed,key:t.key,readOnly:!0,type:"checkbox"})}},heading:{match:ve(A),order:Oe.HIGH,parse:function(e,n,t){return{content:Ae(n,e[2],t),id:Z.slugify(e[2]),level:e[1].length}},react:function(e,n,t){return e.tag="h"+e.level,q(e.tag,{id:e.id,key:t.key},n(e.content,t))}},headingSetext:{match:ve(I),order:Oe.MAX,parse:function(e,n,t){return{content:Ae(n,e[1],t),level:"="===e[2]?1:2,type:"heading"}}},htmlComment:{match:xe(w),order:Oe.HIGH,parse:function(){return{}},react:Ee},image:{match:ke(se),order:Oe.HIGH,parse:function(e){return{alt:e[1],target:He(e[2]),title:e[3]}},react:function(e,n,t){return q("img",{key:t.key,alt:e.alt||void 0,title:e.title||void 0,src:be(e.target)})}},link:{match:ye(ue),order:Oe.LOW,parse:function(e,n,t){return{content:Ie(n,e[1],t),target:He(e[2]),title:e[3]}},react:function(e,n,t){return q("a",{key:t.key,href:be(e.target),title:e.title},n(e.content,t))}},linkAngleBraceStyleDetector:{match:ye(L),order:Oe.MAX,parse:function(e){return{content:[{content:e[1],type:"text"}],target:e[1],type:"link"}}},linkBareUrlDetector:{match:function(e,n){return n.inAnchor?null:ye(C)(e,n)},order:Oe.MAX,parse:function(e){return{content:[{content:e[1],type:"text"}],target:e[1],title:void 0,type:"link"}}},linkMailtoDetector:{match:ye(G),order:Oe.MAX,parse:function(e){var n=e[1],t=e[1];return l.test(t)||(t="mailto:"+t),{content:[{content:n.replace("mailto:",""),type:"text"}],target:t,type:"link"}}},list:{match:function(e,n,t){var r=z.exec(t);return!r||!n._list&&n.inline?null:ie.exec(e=r[1]+e)},order:Oe.HIGH,parse:function(e,n,t){var r=e[2],a=r.length>1,c=a?+r:void 0,o=e[0].replace(u,"\n").match(oe),i=!1;return{items:o.map(function(e,r){var a=ce.exec(e)[0].length,c=new RegExp("^ {1,"+a+"}","gm"),l=e.replace(c,"").replace(ce,""),u=r===o.length-1,s=-1!==l.indexOf("\n\n")||u&&i;i=s;var f,p=t.inline,d=t._list;t._list=!0,s?(t.inline=!1,f=l.replace(T,"\n\n")):(t.inline=!0,f=l.replace(T,""));var m=n(f,t);return t.inline=p,t._list=d,m}),ordered:a,start:c}},react:function(e,n,t){return q(e.ordered?"ol":"ul",{key:t.key,start:e.start},e.items.map(function(e,r){return q("li",{key:r},n(e,t))}))}},newlineCoalescer:{match:ve(y),order:Oe.LOW,parse:Me,react:function(){return"\n"}},paragraph:{match:ve(R),order:Oe.LOW,parse:we,react:function(e,n,t){return q("p",{key:t.key},n(e.content,t))}},ref:{match:ye(W),order:Oe.MAX,parse:function(e){return le[e[1]]={target:e[2],title:e[4]},{}},react:Ee},refImage:{match:ke(_),order:Oe.MAX,parse:function(e){return{alt:e[1]||void 0,ref:e[2]}},react:function(e,n,t){return q("img",{key:t.key,alt:e.alt,src:be(le[e.ref].target),title:le[e.ref].title})}},refLink:{match:ye(B),order:Oe.MAX,parse:function(e,n,t){return{content:n(e[1],t),fallbackContent:n(e[0].replace(N,"\\$1"),t),ref:e[2]}},react:function(e,n,t){return le[e.ref]?q("a",{key:t.key,href:be(le[e.ref].target),title:le[e.ref].title},n(e.content,t)):q("span",{key:t.key},n(e.fallbackContent,t))}},table:{match:ve(j),order:Oe.HIGH,parse:ge,react:function(e,n,t){return q("table",{key:t.key},q("thead",null,q("tr",null,e.header.map(function(r,a){return q("th",{key:a,style:he(e,a)},n(r,t))}))),q("tbody",null,e.cells.map(function(r,a){return q("tr",{key:a},r.map(function(r,a){return q("td",{key:a,style:he(e,a)},n(r,t))}))})))}},tableSeparator:{match:function(e,n){return n.inTable?P.exec(e):null},order:Oe.HIGH,parse:function(){return{type:"tableSeparator"}},react:function(){return" | "}},text:{match:xe(ne),order:Oe.MIN,parse:function(e){return{content:e[0].replace(O,function(e,n){return Z.namedCodesToUnicode[n]?Z.namedCodesToUnicode[n]:e})}},react:function(e){return e.content}},textBolded:{match:ke(Q),order:Oe.MED,parse:function(e,n,t){return{content:n(e[2],t)}},react:function(e,n,t){return q("strong",{key:t.key},n(e.content,t))}},textEmphasized:{match:ke(J),order:Oe.LOW,parse:function(e,n,t){return{content:n(e[2],t)}},react:function(e,n,t){return q("em",{key:t.key},n(e.content,t))}},textEscaped:{match:ke(ee),order:Oe.HIGH,parse:function(e){return{content:e[1],type:"text"}}},textStrikethroughed:{match:ke(Y),order:Oe.LOW,parse:we,react:function(e,n,t){return q("del",{key:t.key},n(e.content,t))}}};!0!==Z.disableParsingRawHTML&&(de.htmlBlock={match:xe(S),order:Oe.HIGH,parse:function(e,n,t){var r,a=e[3].match(re),c=new RegExp("^"+a[1],"gm"),i=e[3].replace(c,""),l=(r=i,fe.some(function(e){return e.test(r)})?Se:Ae),u=e[1].toLowerCase(),s=-1!==o.indexOf(u);t.inAnchor=t.inAnchor||"a"===u;var f=s?e[3]:l(n,i,t);return t.inAnchor=!1,{attrs:K(e[2]),content:f,noInnerParse:s,tag:s?u:e[1]}},react:function(e,n,t){return q(e.tag,Object.assign({key:t.key},e.attrs),e.noInnerParse?e.content:n(e.content,t))}},de.htmlSelfClosing={match:xe(E),order:Oe.HIGH,parse:function(e){return{attrs:K(e[2]||""),tag:e[1]}},react:function(e,n,t){return q(e.tag,Object.assign({},e.attrs,{key:t.key}))}});var me,Le=function(e){var n=Object.keys(e);function t(r,a){for(var c=[],o="";r;)for(var i=0;i<n.length;){var l=n[i],u=e[l],s=u.match(r,a,o);if(s){var f=s[0];r=r.substring(f.length);var p=u.parse(s,t,a);null==p.type&&(p.type=l),c.push(p),o=f;break}i++}return c}return n.sort(function(n,t){var r=e[n].order,a=e[t].order;return r!==a?r-a:n<t?-1:1}),function(e,n){return t(function(e){return e.replace(k,"\n").replace(b,"").replace(D," ")}(e),n)}}(de),Te=(me=function(e){return function(n,t,r){return e[n.type].react(n,t,r)}}(de),function e(n,t){if(void 0===t&&(t={}),Array.isArray(n)){for(var r=t.key,a=[],c=!1,o=0;o<n.length;o++){t.key=o;var i=e(n[o],t),l="string"==typeof i;l&&c?a[a.length-1]+=i:a.push(i),c=l}return t.key=r,a}return me(n,e,t)}),ze=V(e);return ae.length&&ze.props.children.push(q("footer",{key:"footer"},ae.map(function(e){return q("div",{id:Z.slugify(e.identifier),key:e.identifier},e.identifier,Te(Le(e.footnote,{inline:!0})))}))),ze}!function(e){e[e.MAX=0]="MAX",e[e.HIGH=1]="HIGH",e[e.MED=2]="MED",e[e.LOW=3]="LOW",e[e.MIN=4]="MIN"}(Oe||(Oe={}));var Te=function(e){var t=e.children,r=e.options,a=function(e,n){if(null==e)return{};var t,r,a={},c=Object.keys(e);for(r=0;r<c.length;r++)n.indexOf(t=c[r])>=0||(a[t]=e[t]);return a}(e,["children","options"]);return n.default.cloneElement(Le(t,r),a)};Object.assign(Te,{compiler:Le}),module.exports=Te;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|