safe-mdx 0.0.3 → 0.0.5

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 CHANGED
@@ -10,13 +10,15 @@
10
10
 
11
11
  ## Features
12
12
 
13
- - Render MDX without `eval`, so you can render MDX in Cloudflare Workers and Vercel Edge
13
+ - Render MDX without `eval` on the server, so you can render MDX in Cloudflare Workers and Vercel Edge
14
14
  - Works with React Server Components
15
15
  - Supports custom MDX components
16
16
 
17
17
  ## Why
18
18
 
19
- The default MDX renderer uses `eval` (or `new Function(code)`) to render MDX components. This is a security risk if the MdX code comes from untrusted sources and it's not allowed in some environments like Cloudflare Workers.
19
+ The default MDX renderer uses `eval` (or `new Function(code)`) to render MDX components in the server. This is a security risk if the MdX code comes from untrusted sources and it's not allowed in some environments like Cloudflare Workers.
20
+
21
+ For example in an hypothetical platform similar to Notion, where users can write Markdown and publish it as a website, an user could be able to write MDX code that extracts secrets from the server in the SSR pass, using this library that is not possible. This is what happened with Mintlify platform in 2024.
20
22
 
21
23
  Some use cases for this package are:
22
24
 
@@ -47,7 +49,7 @@ This is a paragraph
47
49
 
48
50
  export function Page() {
49
51
  return (
50
- <MdxRenderer
52
+ <SafeMdxRenderer
51
53
  code={code}
52
54
  components={{
53
55
  // You can pass your own components here
@@ -97,7 +99,43 @@ const parser = remark().use(remarkMdx)
97
99
  const mdast = parser.parse(code)
98
100
 
99
101
  export function Page() {
100
- return <MdxRenderer code={code} mdast={mdast} />
102
+ return <SafeMdxRenderer code={code} mdast={mdast} />
103
+ }
104
+ ```
105
+
106
+ ## Reading the frontmatter
107
+
108
+ safe-mdx renderer ignores the frontmatter, to get its values you wil have to parse the MDX to mdast and read it there.
109
+
110
+ ```tsx
111
+ import { SafeMdxRenderer } from 'safe-mdx'
112
+ import { remark } from 'remark'
113
+ import remarkFrontmatter from 'remark-frontmatter'
114
+ import { Yaml } from 'mdast'
115
+ import yaml from 'js-yaml'
116
+ import remarkMdx from 'remark-mdx'
117
+
118
+ const code = `
119
+ ---
120
+ hello: 5
121
+ ---
122
+
123
+ # Hello world
124
+ `
125
+
126
+ export function Page() {
127
+ const parser = remark().use(remarkFrontmatter, ['yaml']).use(remarkMdx)
128
+
129
+ const mdast = parser.parse(code)
130
+
131
+ const yamlFrontmatter = mdast.children.find(
132
+ (node) => node.type === 'yaml',
133
+ ) as Yaml
134
+
135
+ const parsedFrontmatter = yaml.load(yamlFrontmatter.value || '')
136
+
137
+ console.log(parsedFrontmatter)
138
+ return <SafeMdxRenderer code={code} mdast={mdast} />
101
139
  }
102
140
  ```
103
141
 
@@ -120,6 +158,14 @@ export function Page() {
120
158
  }
121
159
  ```
122
160
 
161
+ ## Security
162
+
163
+ safe-mdx is designed to avoid server-side evaluation of untrusted MDX input.
164
+
165
+ However, it's important to note that safe-mdx does not provide protection against client-side vulnerabilities, such as Cross-Site Scripting (XSS) or script injection attacks. While safe-mdx itself does not perform any evaluation or rendering of user-provided content, the rendering library or components used in conjunction with safe-mdx may introduce security risks if not properly configured or sanitized.
166
+
167
+ This is ok if you render your MDX in isolation from each tenant, for example on different subdomains, this way an XSS attack cannot affect all tenants. If instead you render the MDX from different tenants on the same domain, one tenant could steal cookies set from other customers.
168
+
123
169
  ## Limitations
124
170
 
125
171
  These features are not supported yet:
@@ -1,14 +1,14 @@
1
- import { Node, Parent } from 'mdast';
2
- import { Root, RootContent } from 'mdast';
1
+ import { Node, Parent, RootContent } from 'mdast';
2
+ import { Root } from 'mdast';
3
3
  import { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
4
4
  import { ReactNode } from 'react';
5
5
  type MyRootContent = RootContent | Root;
6
6
  export declare function SafeMdxRenderer({ components, code, mdast, }: {
7
7
  components: any;
8
- code?: string | undefined;
8
+ code?: string;
9
9
  mdast?: any;
10
10
  }): any;
11
- declare const nativeTags: readonly ["blockquote", "strong", "em", "del", "hr", "a", "b", "br", "button", "div", "form", "h1", "h2", "h3", "h4", "head", "iframe", "img", "input", "label", "li", "link", "ol", "p", "path", "picture", "script", "section", "source", "span", "sub", "sup", "svg", "table", "tbody", "td", "th", "thead", "tr", "ul", "video", "code", "pre"];
11
+ declare const nativeTags: readonly ["blockquote", "strong", "em", "del", "hr", "a", "b", "br", "button", "div", "form", "h1", "h2", "h3", "h4", "head", "iframe", "img", "input", "label", "li", "link", "ol", "p", "path", "picture", "script", "section", "source", "span", "sub", "sup", "svg", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "ul", "video", "code", "pre"];
12
12
  type ComponentsMap = {
13
13
  [k in (typeof nativeTags)[number]]?: any;
14
14
  };
@@ -21,9 +21,9 @@ export declare class MdastToJsx {
21
21
  message: string;
22
22
  }[];
23
23
  constructor({ code, mdast, components, }: {
24
- code?: string | undefined;
24
+ code?: string;
25
25
  mdast?: any;
26
- components?: ComponentsMap | undefined;
26
+ components?: ComponentsMap;
27
27
  });
28
28
  mapMdastChildren(node: any): any;
29
29
  mapJsxChildren(node: any): any;
@@ -1 +1 @@
1
- {"version":3,"file":"safe-mdx.d.ts","sourceRoot":"","sources":["../src/safe-mdx.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAGpC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAKzE,OAAO,EAAY,SAAS,EAAE,MAAM,OAAO,CAAA;AAE3C,KAAK,aAAa,GAAG,WAAW,GAAG,IAAI,CAAA;AASvC,wBAAgB,eAAe,CAAC,EAC5B,UAAU,EACV,IAAS,EACT,KAAmB,GACtB;;;;CAAA,OAIA;AAED,QAAA,MAAM,UAAU,qVA4CN,CAAA;AAEV,KAAK,aAAa,GAAG;KAAG,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG;CAAE,C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UAAU,8VA6CN,CAAA;AAEV,KAAK,aAAa,GAAG;KAAG,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG;CAAE,CAAA;AAEjE,qBAAa,UAAU;IACnB,KAAK,EAAE,aAAa,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAK;IACnB,CAAC,EAAE,aAAa,CAAA;IAChB,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAK;gBACtB,EACR,IAAS,EACT,KAAwB,EACxB,UAAgC,GACnC;;;;KAAA;IAaD,gBAAgB,CAAC,IAAI,EAAE,GAAG;IAiB1B,cAAc,CAAC,IAAI,EAAE,GAAG;IAiBxB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS;IAsC9C,GAAG;IAQH,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS;CAwOnD;AAED,wBAAgB,WAAW,CACvB,IAAI,EAAE,iBAAiB,GAAG,iBAAiB,EAC3C,OAAO,GAAE,CAAC,GAAG,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,KAAK,IAAoB,mBAoE9D;AAcD,wBAAgB,QAAQ,CACpB,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,KAAK,GAAG,SAiBpC"}
package/dist/safe-mdx.js CHANGED
@@ -53,6 +53,7 @@ const nativeTags = [
53
53
  'table',
54
54
  'tbody',
55
55
  'td',
56
+ 'tfoot',
56
57
  'th',
57
58
  'thead',
58
59
  'tr',
@@ -62,20 +63,30 @@ const nativeTags = [
62
63
  'pre',
63
64
  ];
64
65
  export class MdastToJsx {
66
+ mdast;
67
+ str;
68
+ jsxStr = '';
69
+ c;
70
+ errors = [];
65
71
  constructor({ code = '', mdast = undefined, components = {}, }) {
66
- this.jsxStr = '';
67
- this.errors = [];
68
72
  this.str = code;
69
73
  this.mdast = mdast || mdxParser.parse(code);
70
- this.c = Object.assign(Object.assign({}, Object.fromEntries(nativeTags.map((tag) => {
71
- return [tag, tag];
72
- }))), components);
74
+ this.c = {
75
+ ...Object.fromEntries(nativeTags.map((tag) => {
76
+ return [tag, tag];
77
+ })),
78
+ ...components,
79
+ };
73
80
  }
74
81
  mapMdastChildren(node) {
75
- var _a;
76
- const res = (_a = node.children) === null || _a === void 0 ? void 0 : _a.flatMap((child) => this.mdastTransformer(child)).filter(Boolean);
82
+ const res = node.children
83
+ ?.flatMap((child) => this.mdastTransformer(child))
84
+ .filter(Boolean);
77
85
  if (Array.isArray(res)) {
78
- if (res.length === 1) {
86
+ if (!res.length) {
87
+ return null;
88
+ }
89
+ else if (res.length === 1) {
79
90
  return res[0];
80
91
  }
81
92
  else {
@@ -85,10 +96,14 @@ export class MdastToJsx {
85
96
  return res || null;
86
97
  }
87
98
  mapJsxChildren(node) {
88
- var _a;
89
- const res = (_a = node.children) === null || _a === void 0 ? void 0 : _a.flatMap((child, i) => this.jsxTransformer(child)).filter(Boolean);
99
+ const res = node.children
100
+ ?.flatMap((child, i) => this.jsxTransformer(child))
101
+ .filter(Boolean);
90
102
  if (Array.isArray(res)) {
91
- if (res.length === 1) {
103
+ if (!res.length) {
104
+ return null;
105
+ }
106
+ else if (res.length === 1) {
92
107
  return res[0];
93
108
  }
94
109
  else {
@@ -118,7 +133,7 @@ export class MdastToJsx {
118
133
  this.errors.push(err);
119
134
  });
120
135
  let attrs = Object.fromEntries(attrsList);
121
- return (_jsx(Component, Object.assign({}, attrs, { children: this.mapJsxChildren(node) })));
136
+ return (_jsx(Component, { ...attrs, children: this.mapJsxChildren(node) }));
122
137
  }
123
138
  default: {
124
139
  return this.mdastTransformer(node);
@@ -133,21 +148,20 @@ export class MdastToJsx {
133
148
  return res;
134
149
  }
135
150
  mdastTransformer(node) {
136
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
137
151
  if (!node) {
138
152
  return [];
139
153
  }
140
154
  switch (node.type) {
141
155
  case 'mdxjsEsm': {
142
- const start = (_b = (_a = node.position) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.offset;
143
- const end = (_d = (_c = node.position) === null || _c === void 0 ? void 0 : _c.end) === null || _d === void 0 ? void 0 : _d.offset;
156
+ const start = node.position?.start?.offset;
157
+ const end = node.position?.end?.offset;
144
158
  let text = this.str.slice(start, end);
145
159
  return [];
146
160
  }
147
161
  case 'mdxJsxTextElement':
148
162
  case 'mdxJsxFlowElement': {
149
- const start = (_f = (_e = node.position) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.offset;
150
- const end = (_h = (_g = node.position) === null || _g === void 0 ? void 0 : _g.end) === null || _h === void 0 ? void 0 : _h.offset;
163
+ const start = node.position?.start?.offset;
164
+ const end = node.position?.end?.offset;
151
165
  const text = this.str.slice(start, end);
152
166
  try {
153
167
  this.jsxStr = text;
@@ -179,7 +193,7 @@ export class MdastToJsx {
179
193
  }
180
194
  case 'heading': {
181
195
  const level = node.depth;
182
- const Tag = `h${level}`;
196
+ const Tag = this.c[`h${level}`] ?? `h${level}`;
183
197
  return _jsx(Tag, { children: this.mapMdastChildren(node) });
184
198
  }
185
199
  case 'paragraph': {
@@ -207,7 +221,7 @@ export class MdastToJsx {
207
221
  }
208
222
  case 'listItem': {
209
223
  // https://github.com/syntax-tree/mdast-util-gfm-task-list-item#syntax-tree
210
- if ((node === null || node === void 0 ? void 0 : node.checked) != null) {
224
+ if (node?.checked != null) {
211
225
  return (_jsx(this.c.li, { "data-checked": node.checked, children: this.mapMdastChildren(node) }));
212
226
  }
213
227
  return _jsx(this.c.li, { children: this.mapMdastChildren(node) });
@@ -252,7 +266,7 @@ export class MdastToJsx {
252
266
  }
253
267
  case 'table': {
254
268
  const [head, ...body] = React.Children.toArray(this.mapMdastChildren(node));
255
- return (_jsxs(this.c.table, { children: [head && _jsx(this.c.thead, { children: head }), !!(body === null || body === void 0 ? void 0 : body.length) && _jsx(this.c.tbody, { children: body })] }));
269
+ return (_jsxs(this.c.table, { children: [head && _jsx(this.c.thead, { children: head }), !!body?.length && _jsx(this.c.tbody, { children: body })] }));
256
270
  }
257
271
  case 'tableRow': {
258
272
  return (_jsx(this.c.tr, { className: '', children: this.mapMdastChildren(node) }));
@@ -281,8 +295,8 @@ export class MdastToJsx {
281
295
  return [];
282
296
  }
283
297
  case 'html': {
284
- const start = (_k = (_j = node.position) === null || _j === void 0 ? void 0 : _j.start) === null || _k === void 0 ? void 0 : _k.offset;
285
- const end = (_m = (_l = node.position) === null || _l === void 0 ? void 0 : _l.end) === null || _m === void 0 ? void 0 : _m.offset;
298
+ const start = node.position?.start?.offset;
299
+ const end = node.position?.end?.offset;
286
300
  const text = this.str.slice(start, end);
287
301
  if (!text) {
288
302
  return [];
@@ -335,7 +349,7 @@ export function getJsxAttrs(node, onError = console.error) {
335
349
  if (v === null) {
336
350
  return [attr.name, true];
337
351
  }
338
- if ((v === null || v === void 0 ? void 0 : v.type) === 'mdxJsxAttributeValueExpression') {
352
+ if (v?.type === 'mdxJsxAttributeValueExpression') {
339
353
  if (v.value === 'true') {
340
354
  return [attr.name, true];
341
355
  }
@@ -1 +1 @@
1
- {"version":3,"file":"safe-mdx.js","sourceRoot":"","sources":["../src/safe-mdx.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,OAAO,iBAAiB,MAAM,oBAAoB,CAAA;AAIlD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,SAAS,MAAM,YAAY,CAAA;AAElC,OAAO,EAAE,QAAQ,EAAa,MAAM,OAAO,CAAA;AAI3C,MAAM,SAAS,GAAG,MAAM,EAAE;KACrB,GAAG,C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MAAM,CAAA;AACjB,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAC9B,IAAI;QACA,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACzB;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,IAAI,CAAA;KACd;AACL,CAAC"}
@@ -2,7 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  import dedent from 'dedent';
4
4
  import { test, expect } from 'vitest';
5
- import { MdastToJsx } from './safe-mdx';
5
+ import { MdastToJsx } from './safe-mdx.js';
6
+ import { renderToStaticMarkup } from 'react-dom/server';
6
7
  void React;
7
8
  const components = {
8
9
  Heading({ level, children }) {
@@ -12,8 +13,9 @@ const components = {
12
13
  function render(code) {
13
14
  const visitor = new MdastToJsx({ code, components });
14
15
  const result = visitor.run();
16
+ const html = renderToStaticMarkup(result);
15
17
  // console.log(JSON.stringify(result, null, 2))
16
- return { result, errors: visitor.errors || [] };
18
+ return { result, errors: visitor.errors || [], html };
17
19
  }
18
20
  test('basic', () => {
19
21
  expect(render(dedent `
@@ -23,6 +25,31 @@ test('basic', () => {
23
25
  `)).toMatchInlineSnapshot(`
24
26
  {
25
27
  "errors": [],
28
+ "html": "<h1>Hello</h1><p>i am a paragraph</p>",
29
+ "result": <React.Fragment>
30
+ <h1>
31
+ Hello
32
+ </h1>
33
+ <p>
34
+ i am a paragraph
35
+ </p>
36
+ </React.Fragment>,
37
+ }
38
+ `);
39
+ });
40
+ test('frontmatter', () => {
41
+ expect(render(dedent `
42
+ ---
43
+ hello: 5
44
+ ---
45
+
46
+ # Hello
47
+
48
+ i am a paragraph
49
+ `)).toMatchInlineSnapshot(`
50
+ {
51
+ "errors": [],
52
+ "html": "<h1>Hello</h1><p>i am a paragraph</p>",
26
53
  "result": <React.Fragment>
27
54
  <h1>
28
55
  Hello
@@ -45,6 +72,7 @@ test('table', () => {
45
72
  `)).toMatchInlineSnapshot(`
46
73
  {
47
74
  "errors": [],
75
+ "html": "<h1>Hello</h1><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead><tbody><tr class=""><td class="">col 3 is</td><td class="">right-aligned</td><td class="">$1600</td></tr><tr class=""><td class="">col 2 is</td><td class="">centered</td><td class="">$12</td></tr></tbody></table>",
48
76
  "result": <React.Fragment>
49
77
  <h1>
50
78
  Hello
@@ -126,6 +154,7 @@ test('table, only head', () => {
126
154
  `)).toMatchInlineSnapshot(`
127
155
  {
128
156
  "errors": [],
157
+ "html": "<h1>Hello</h1><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead></table>",
129
158
  "result": <React.Fragment>
130
159
  <h1>
131
160
  Hello
@@ -163,6 +192,7 @@ test('inline jsx', () => {
163
192
  `)).toMatchInlineSnapshot(`
164
193
  {
165
194
  "errors": [],
195
+ "html": "<p><h1>hello</h1></p>",
166
196
  "result": <React.Fragment>
167
197
  <p>
168
198
  <Heading
@@ -183,6 +213,7 @@ test('block jsx', () => {
183
213
  `)).toMatchInlineSnapshot(`
184
214
  {
185
215
  "errors": [],
216
+ "html": "<h1><blockquote><p>hello</p></blockquote></h1>",
186
217
  "result": <React.Fragment>
187
218
  <Heading
188
219
  level={2}
@@ -197,6 +228,30 @@ test('block jsx', () => {
197
228
  }
198
229
  `);
199
230
  });
231
+ test('complex jsx, self closing tags', () => {
232
+ expect(render(dedent `
233
+ # hello <br />
234
+
235
+ <br />
236
+
237
+ content
238
+ `)).toMatchInlineSnapshot(`
239
+ {
240
+ "errors": [],
241
+ "html": "<h1>hello <br/></h1><br/><p>content</p>",
242
+ "result": <React.Fragment>
243
+ <h1>
244
+ hello
245
+ <br />
246
+ </h1>
247
+ <br />
248
+ <p>
249
+ content
250
+ </p>
251
+ </React.Fragment>,
252
+ }
253
+ `);
254
+ });
200
255
  test('missing components are ignored', () => {
201
256
  expect(render(dedent `
202
257
  <MissingComponent level={2} />
@@ -207,6 +262,7 @@ test('missing components are ignored', () => {
207
262
  "message": "Unsupported jsx component MissingComponent",
208
263
  },
209
264
  ],
265
+ "html": "",
210
266
  "result": <React.Fragment />,
211
267
  }
212
268
  `);
@@ -248,6 +304,7 @@ test('props parsing', () => {
248
304
  "message": "Expressions in jsx props are not supported (...{ spread: true })",
249
305
  },
250
306
  ],
307
+ "html": "<h1><p>hi</p></h1>",
251
308
  "result": <React.Fragment>
252
309
  <Heading
253
310
  backTick="some \${expr} value"
@@ -278,6 +335,7 @@ test('breaks', () => {
278
335
  `)).toMatchInlineSnapshot(`
279
336
  {
280
337
  "errors": [],
338
+ "html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p>",
281
339
  "result": <React.Fragment>
282
340
  <p>
283
341
  To have a line break without a paragraph, you will need to use two trailing spaces.
@@ -318,7 +376,7 @@ test('kitchen sink', () => {
318
376
 
319
377
  ## Headers
320
378
 
321
- \`\`\`no-highlight
379
+
322
380
  # H1
323
381
  ## H2
324
382
  ### H3
@@ -333,7 +391,7 @@ test('kitchen sink', () => {
333
391
 
334
392
  Alt-H2
335
393
  ------
336
- \`\`\`
394
+
337
395
 
338
396
  # H1
339
397
  ## H2
@@ -710,6 +768,112 @@ test('kitchen sink', () => {
710
768
  "message": "Unsupported jsx component dl",
711
769
  },
712
770
  ],
771
+ "html": "<h1>Markdown Kitchen Sink</h1><p>This file is <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" title="">https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet</a> plus a few fixes and additions. Used by <a href="https://github.com/obedm503/bootmark" title="">obedm503/bootmark</a> to <a href="https://obedm503.github.io/bootmark/docs/markdown-cheatsheet.html" title="">demonstrate</a> it&#x27;s styling features.</p><p>This is intended as a quick reference and showcase. For more complete info, see <a href="http://daringfireball.net/projects/markdown/" title="">John Gruber&#x27;s original spec</a> and the <a href="http://github.github.com/github-flavored-markdown/" title="">Github-flavored Markdown info page</a>.</p><p>Note that there is also a <a href="./Markdown-Here-Cheatsheet" title="">Cheatsheet specific to Markdown Here</a> if that&#x27;s what you&#x27;re looking for. You can also check out <a href="./Other-Markdown-Tools" title="">more Markdown tools</a>.</p><h5>Table of Contents</h5><p><a href="#headers" title="">Headers</a><br/><a href="#emphasis" title="">Emphasis</a><br/><a href="#lists" title="">Lists</a><br/><a href="#links" title="">Links</a><br/><a href="#images" title="">Images</a><br/><a href="#code" title="">Code and Syntax Highlighting</a><br/><a href="#tables" title="">Tables</a><br/><a href="#blockquotes" title="">Blockquotes</a><br/><a href="#html" title="">Inline HTML</a><br/><a href="#hr" title="">Horizontal Rule</a><br/><a href="#lines" title="">Line Breaks</a><br/><a href="#videos" title="">YouTube Videos</a></p><a name="headers"></a><h2>Headers</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><a name="emphasis"></a><h2>Emphasis</h2><pre><code>Emphasis, aka italics, with *asterisks* or _underscores_.
772
+
773
+ Strong emphasis, aka bold, with **asterisks** or __underscores__.
774
+
775
+ Combined emphasis with **asterisks and _underscores_**.
776
+
777
+ Strikethrough uses two tildes. ~~Scratch this.~~</code></pre><p>Emphasis, aka italics, with <em>asterisks</em> or <em>underscores</em>.</p><p>Strong emphasis, aka bold, with <strong>asterisks</strong> or <strong>underscores</strong>.</p><p>Combined emphasis with <strong>asterisks and <em>underscores</em></strong>.</p><p>Strikethrough uses two tildes. <del>Scratch this.</del></p><a name="lists"></a><h2>Lists</h2><p>(In this example, leading and trailing spaces are shown with with dots: ⋅)</p><pre><code>1. First ordered list item
778
+ 2. Another item
779
+ ⋅⋅* Unordered sub-list.
780
+ 1. Actual numbers don&#x27;t matter, just that it&#x27;s a number
781
+ ⋅⋅1. Ordered sub-list
782
+ 4. And another item.
783
+
784
+ ⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we&#x27;ll use three here to also align the raw Markdown).
785
+
786
+ ⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
787
+ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
788
+ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
789
+
790
+ * Unordered list can use asterisks
791
+ - Or minuses
792
+ + Or pluses</code></pre><ol start="1"><li><p>First ordered list item</p></li><li><p>Another item</p></li></ol><ul><li><p>Unordered sub-list.</p></li></ul><ol start="1"><li><p>Actual numbers don&#x27;t matter, just that it&#x27;s a number</p></li><li><p>Ordered sub-list</p></li><li><p>And another item.</p><p>You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we&#x27;ll use three here to also align the raw Markdown).</p><p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p></li></ol><ul><li><p>Unordered list can use asterisks</p></li></ul><ul><li><p>Or minuses</p></li></ul><ul><li><p>Or pluses</p></li></ul><a name="links"></a><h2>Links</h2><p>There are two ways to create links.</p><pre><code>[I&#x27;m an inline-style link](https://www.google.com)
793
+
794
+ [I&#x27;m an inline-style link with title](https://www.google.com &quot;Google&#x27;s Homepage&quot;)
795
+
796
+ [I&#x27;m a reference-style link][Arbitrary case-insensitive reference text]
797
+
798
+ [I&#x27;m a relative reference to a repository file](../blob/master/LICENSE)
799
+
800
+ [You can use numbers for reference-style link definitions][1]
801
+
802
+ Or leave it empty and use the [link text itself].
803
+
804
+ URLs and URLs in angle brackets will automatically get turned into links.
805
+ http://www.example.com and sometimes
806
+ example.com (but not on Github, for example).
807
+
808
+ Some text to show that the reference links can follow later.
809
+
810
+ [arbitrary case-insensitive reference text]: https://www.mozilla.org
811
+ [1]: http://slashdot.org
812
+ [link text itself]: http://www.reddit.com</code></pre><p><a href="https://www.google.com" title="">I&#x27;m an inline-style link</a></p><p><a href="https://www.google.com" title="Google&#x27;s Homepage">I&#x27;m an inline-style link with title</a></p><p><a href="https://www.mozilla.org">I&#x27;m a reference-style link</a></p><p><a href="../blob/master/LICENSE" title="">I&#x27;m a relative reference to a repository file</a></p><p><a href="http://slashdot.org">You can use numbers for reference-style link definitions</a></p><p>Or leave it empty and use the <a href="http://www.reddit.com">link text itself</a>.</p><p>URLs and URLs in angle brackets will automatically get turned into links.
813
+ <a href="http://www.example.com" title="">http://www.example.com</a> and sometimes
814
+ example.com (but not on Github, for example).</p><p>Some text to show that the reference links can follow later.</p><a name="images"></a><h2>Images</h2><pre><code>Here&#x27;s our logo (hover to see the title text):
815
+
816
+ Inline-style:
817
+ ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png &quot;Logo Title Text 1&quot;)
818
+
819
+ Reference-style:
820
+ ![alt text][logo]
821
+
822
+ [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png &quot;Logo Title Text 2&quot;</code></pre><p>Here&#x27;s our logo (hover to see the title text):</p><p>Inline-style:
823
+ <img src="https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png" alt="alt text" title="Logo Title Text 1"/></p><p>Reference-style:
824
+ </p><a name="code"></a><h2>Code and Syntax Highlighting</h2><p>Code blocks are part of the Markdown spec, but syntax highlighting isn&#x27;t. However, many renderers -- like Github&#x27;s and <em>Markdown Here</em> -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. <em>Markdown Here</em> supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the <a href="http://softwaremaniacs.org/media/soft/highlight/test.html" title="">highlight.js demo page</a>.</p><pre><code>Inline \`code\` has \`back-ticks around\` it.</code></pre><p>Inline <code>code</code> has <code>back-ticks around</code> it.</p><p>Blocks of code are either fenced by lines with three back-ticks <code>\`\`\`</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they&#x27;re easier and only they support syntax highlighting.</p><pre><code>var s = &quot;JavaScript syntax highlighting&quot;;
825
+ alert(s);</code></pre><pre><code>s = &quot;Python syntax highlighting&quot;
826
+ print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
827
+ But let&#x27;s throw in a &amp;lt;b&amp;gt;tag&amp;lt;/b&amp;gt;.</code></pre><pre><code>var s = &quot;JavaScript syntax highlighting&quot;;
828
+ alert(s);</code></pre><pre><code>s = &quot;Python syntax highlighting&quot;
829
+ print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
830
+ But let&#x27;s throw in a &lt;b&gt;tag&lt;/b&gt;.</code></pre><a name="tables"></a><h2>Tables</h2><p>Tables aren&#x27;t part of the core Markdown spec, but they are part of GFM and <em>Markdown Here</em> supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.</p><pre><code>Colons can be used to align columns.
831
+
832
+ | Tables | Are | Cool |
833
+ | ------------- |:-------------:| -----:|
834
+ | col 3 is | right-aligned | $1600 |
835
+ | col 2 is | centered | $12 |
836
+ | zebra stripes | are neat | $1 |
837
+
838
+ There must be at least 3 dashes separating each header cell.
839
+ The outer pipes (|) are optional, and you don&#x27;t need to make the
840
+ raw Markdown line up prettily. You can also use inline Markdown.
841
+
842
+ Markdown | Less | Pretty
843
+ --- | --- | ---
844
+ *Still* | \`renders\` | **nicely**
845
+ 1 | 2 | 3</code></pre><p>Colons can be used to align columns.</p><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead><tbody><tr class=""><td class="">col 3 is</td><td class="">right-aligned</td><td class="">$1600</td></tr><tr class=""><td class="">col 2 is</td><td class="">centered</td><td class="">$12</td></tr><tr class=""><td class="">zebra stripes</td><td class="">are neat</td><td class="">$1</td></tr></tbody></table><p>There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don&#x27;t need to make the raw Markdown line up prettily. You can also use inline Markdown.</p><table><thead><tr class=""><td class="">Markdown</td><td class="">Less</td><td class="">Pretty</td></tr></thead><tbody><tr class=""><td class=""><em>Still</em></td><td class=""><code>renders</code></td><td class=""><strong>nicely</strong></td></tr><tr class=""><td class="">1</td><td class="">2</td><td class="">3</td></tr></tbody></table><a name="blockquotes"></a><h2>Blockquotes</h2><pre><code>&gt; Blockquotes are very handy in email to emulate reply text.
846
+ &gt; This line is part of the same quote.
847
+
848
+ Quote break.
849
+
850
+ &gt; This is a very long line that will still be quoted properly when it wraps. Oh boy let&#x27;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. </code></pre><blockquote><p>Blockquotes are very handy in email to emulate reply text.
851
+ This line is part of the same quote.</p></blockquote><p>Quote break.</p><blockquote><p>This is a very long line that will still be quoted properly when it wraps. Oh boy let&#x27;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can <em>put</em> <strong>Markdown</strong> into a blockquote.</p></blockquote><a name="html"></a><h2>Inline HTML</h2><p>You can also use raw HTML in your Markdown, and it&#x27;ll mostly work pretty well.</p><pre><code>&lt;dl&gt;
852
+ &lt;dt&gt;Definition list&lt;/dt&gt;
853
+ &lt;dd&gt;Is something people use sometimes.&lt;/dd&gt;
854
+
855
+ &lt;dt&gt;Markdown in HTML&lt;/dt&gt;
856
+ &lt;dd&gt;Does *not* work **very** well. Use HTML &lt;em&gt;tags&lt;/em&gt;.&lt;/dd&gt;
857
+ &lt;/dl&gt;</code></pre><a name="hr"></a><h2>Horizontal Rule</h2><pre><code>Three or more...
858
+
859
+ ---
860
+
861
+ Hyphens
862
+
863
+ ***
864
+
865
+ Asterisks
866
+
867
+ ___
868
+
869
+ Underscores</code></pre><p>Three or more...</p><hr/><p>Hyphens</p><hr/><p>Asterisks</p><hr/><p>Underscores</p><a name="lines"></a><h2>Line Breaks</h2><p>My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You&#x27;ll soon learn to get what you want. &quot;Markdown Toggle&quot; is your friend.</p><p>Here are some things to try out:</p><pre><code>Here&#x27;s a line for us to start with.
870
+
871
+ This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
872
+
873
+ This line is also a separate paragraph, but...
874
+ This line is only separated by a single newline, so it&#x27;s a separate line in the *same paragraph*.</code></pre><p>Here&#x27;s a line for us to start with.</p><p>This line is separated from the one above by two newlines, so it will be a <em>separate paragraph</em>.</p><p>This line is also begins a separate paragraph, but...<br/>This line is only separated by a single newline, so it&#x27;s a separate line in the <em>same paragraph</em>.</p><p>(Technical note: <em>Markdown Here</em> uses GFM line breaks, so there&#x27;s no need to use MD&#x27;s two-space line breaks.)</p><a name="videos"></a><h2>YouTube Videos</h2><p>They can&#x27;t be added directly but you can add an image with a link to the video like this:</p><pre><code>&lt;a href=&quot;http://www.youtube.com/watch?feature=player_embedded&amp;v=YOUTUBE_VIDEO_ID_HERE
875
+ &quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg&quot;
876
+ alt=&quot;IMAGE ALT TEXT HERE&quot; width=&quot;240&quot; height=&quot;180&quot; border=&quot;10&quot; /&gt;&lt;/a&gt;</code></pre><p>Or, in pure Markdown, but losing the image sizing and border:</p><pre><code>[![IMAGE ALT TEXT HERE](http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg)](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)</code></pre>",
713
877
  "result": <React.Fragment>
714
878
  <h1>
715
879
  Markdown Kitchen Sink
@@ -866,24 +1030,33 @@ test('kitchen sink', () => {
866
1030
  <h2>
867
1031
  Headers
868
1032
  </h2>
869
- <pre>
870
- <code>
871
- # H1
872
- ## H2
873
- ### H3
874
- #### H4
875
- ##### H5
876
- ###### H6
877
-
878
- Alternatively, for H1 and H2, an underline-ish style:
879
-
880
- Alt-H1
881
- ======
882
-
883
- Alt-H2
884
- ------
885
- </code>
886
- </pre>
1033
+ <h1>
1034
+ H1
1035
+ </h1>
1036
+ <h2>
1037
+ H2
1038
+ </h2>
1039
+ <h3>
1040
+ H3
1041
+ </h3>
1042
+ <h4>
1043
+ H4
1044
+ </h4>
1045
+ <h5>
1046
+ H5
1047
+ </h5>
1048
+ <h6>
1049
+ H6
1050
+ </h6>
1051
+ <p>
1052
+ Alternatively, for H1 and H2, an underline-ish style:
1053
+ </p>
1054
+ <h1>
1055
+ Alt-H1
1056
+ </h1>
1057
+ <h2>
1058
+ Alt-H2
1059
+ </h2>
887
1060
  <h1>
888
1061
  H1
889
1062
  </h1>
@@ -1 +1 @@
1
- {"version":3,"file":"safe-mdx.test.js","sourceRoot":"","sources":["../src/safe-mdx.test.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,KAAK,KAAK,CAAA;AAEV,MAAM,UAAU,GAAG;IACf,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE;QACvB,OAAO,uBAAK,QAAQ,GAAM,CAAA;IAC9B,CAAC;CACG,CAAA;AAER,SAAS,MAAM,CAAC,IAAI;IAChB,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;IACpD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAC5B,+CAA+C;IAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAA;AACnD,CAAC;AAED,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4hCvB,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,49 +1,53 @@
1
1
  {
2
- "name": "safe-mdx",
3
- "version": "0.0.3",
4
- "private": false,
5
- "description": "Render MDX in React without eval",
6
- "repository": "https://github.com/holocron-hq/safe-mdx",
7
- "type": "module",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/safe-mdx.d.ts",
11
- "default": "./dist/safe-mdx.js"
12
- },
13
- "./src/*": "./src/*.ts",
14
- "./package.json": "./package.json"
2
+ "name": "safe-mdx",
3
+ "version": "0.0.5",
4
+ "private": false,
5
+ "description": "Render MDX in React without eval",
6
+ "repository": "https://github.com/holocron-hq/safe-mdx",
7
+ "type": "module",
8
+ "types": "./dist/safe-mdx.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/safe-mdx.d.ts",
12
+ "default": "./dist/safe-mdx.js"
15
13
  },
16
- "scripts": {
17
- "build": "tsc",
18
- "test": "vitest",
19
- "prepublishOnly": "pnpm build"
20
- },
21
- "files": [
22
- "dist",
23
- "src"
24
- ],
25
- "keywords": [
26
- "mdx"
27
- ],
28
- "author": "remorses <beats.by.morse@gmail.com>",
29
- "license": "MIT",
30
- "peerDependencies": {
31
- "react": "*"
32
- },
33
- "dependencies": {
34
- "html-to-jsx-transform": "^1.1.0",
35
- "mdast": "^3.0.0",
36
- "remark": "^15.0.1",
37
- "remark-frontmatter": "^5.0.0",
38
- "remark-gfm": "^4.0.0",
39
- "remark-mdx": "^3.0.0"
40
- },
41
- "devDependencies": {
42
- "@types/mdast": "^4.0.3",
43
- "@types/node": "^20.10.0",
44
- "@types/react": "18.2.15",
45
- "dedent": "^1.2.0",
46
- "mdast-util-mdx-jsx": "^3.0.0",
47
- "react": "^18.2.0"
48
- }
49
- }
14
+ "./src/*": "./src/*.tsx",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "src"
20
+ ],
21
+ "keywords": [
22
+ "mdx"
23
+ ],
24
+ "author": "remorses <beats.by.morse@gmail.com>",
25
+ "license": "MIT",
26
+ "peerDependencies": {
27
+ "react": "*"
28
+ },
29
+ "dependencies": {
30
+ "html-to-jsx-transform": "^1.0.0",
31
+ "remark": "^15.0.0",
32
+ "remark-frontmatter": "^5.0.0",
33
+ "remark-gfm": "^4.0.0",
34
+ "remark-mdx": "^3.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/mdast": "^4.0.0",
38
+ "@types/node": "^20.0.0",
39
+ "@types/react": "^18.3.11",
40
+ "@types/react-dom": "^18.0.0",
41
+ "@vitest/coverage-v8": "^1.0.0",
42
+ "dedent": "^1.5.1",
43
+ "mdast-util-mdx-jsx": "^3.0.0",
44
+ "react": "^18.3.1",
45
+ "react-dom": "^18.3.1",
46
+ "typescript": "5.5.2",
47
+ "vitest": "^1.6.0"
48
+ },
49
+ "scripts": {
50
+ "build": "tsc",
51
+ "test": "vitest run --coverage"
52
+ }
53
+ }
@@ -1,7 +1,8 @@
1
1
  import React from 'react'
2
2
  import dedent from 'dedent'
3
3
  import { test, expect } from 'vitest'
4
- import { MdastToJsx } from './safe-mdx'
4
+ import { MdastToJsx } from './safe-mdx.js'
5
+ import { renderToStaticMarkup } from 'react-dom/server'
5
6
  void React
6
7
 
7
8
  const components = {
@@ -13,8 +14,9 @@ const components = {
13
14
  function render(code) {
14
15
  const visitor = new MdastToJsx({ code, components })
15
16
  const result = visitor.run()
17
+ const html = renderToStaticMarkup(result)
16
18
  // console.log(JSON.stringify(result, null, 2))
17
- return { result, errors: visitor.errors || [] }
19
+ return { result, errors: visitor.errors || [], html }
18
20
  }
19
21
 
20
22
  test('basic', () => {
@@ -27,6 +29,33 @@ test('basic', () => {
27
29
  ).toMatchInlineSnapshot(`
28
30
  {
29
31
  "errors": [],
32
+ "html": "<h1>Hello</h1><p>i am a paragraph</p>",
33
+ "result": <React.Fragment>
34
+ <h1>
35
+ Hello
36
+ </h1>
37
+ <p>
38
+ i am a paragraph
39
+ </p>
40
+ </React.Fragment>,
41
+ }
42
+ `)
43
+ })
44
+ test('frontmatter', () => {
45
+ expect(
46
+ render(dedent`
47
+ ---
48
+ hello: 5
49
+ ---
50
+
51
+ # Hello
52
+
53
+ i am a paragraph
54
+ `),
55
+ ).toMatchInlineSnapshot(`
56
+ {
57
+ "errors": [],
58
+ "html": "<h1>Hello</h1><p>i am a paragraph</p>",
30
59
  "result": <React.Fragment>
31
60
  <h1>
32
61
  Hello
@@ -51,6 +80,7 @@ test('table', () => {
51
80
  ).toMatchInlineSnapshot(`
52
81
  {
53
82
  "errors": [],
83
+ "html": "<h1>Hello</h1><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead><tbody><tr class=""><td class="">col 3 is</td><td class="">right-aligned</td><td class="">$1600</td></tr><tr class=""><td class="">col 2 is</td><td class="">centered</td><td class="">$12</td></tr></tbody></table>",
54
84
  "result": <React.Fragment>
55
85
  <h1>
56
86
  Hello
@@ -134,6 +164,7 @@ test('table, only head', () => {
134
164
  ).toMatchInlineSnapshot(`
135
165
  {
136
166
  "errors": [],
167
+ "html": "<h1>Hello</h1><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead></table>",
137
168
  "result": <React.Fragment>
138
169
  <h1>
139
170
  Hello
@@ -174,6 +205,7 @@ test('inline jsx', () => {
174
205
  ).toMatchInlineSnapshot(`
175
206
  {
176
207
  "errors": [],
208
+ "html": "<p><h1>hello</h1></p>",
177
209
  "result": <React.Fragment>
178
210
  <p>
179
211
  <Heading
@@ -197,6 +229,7 @@ test('block jsx', () => {
197
229
  ).toMatchInlineSnapshot(`
198
230
  {
199
231
  "errors": [],
232
+ "html": "<h1><blockquote><p>hello</p></blockquote></h1>",
200
233
  "result": <React.Fragment>
201
234
  <Heading
202
235
  level={2}
@@ -211,6 +244,32 @@ test('block jsx', () => {
211
244
  }
212
245
  `)
213
246
  })
247
+ test('complex jsx, self closing tags', () => {
248
+ expect(
249
+ render(dedent`
250
+ # hello <br />
251
+
252
+ <br />
253
+
254
+ content
255
+ `),
256
+ ).toMatchInlineSnapshot(`
257
+ {
258
+ "errors": [],
259
+ "html": "<h1>hello <br/></h1><br/><p>content</p>",
260
+ "result": <React.Fragment>
261
+ <h1>
262
+ hello
263
+ <br />
264
+ </h1>
265
+ <br />
266
+ <p>
267
+ content
268
+ </p>
269
+ </React.Fragment>,
270
+ }
271
+ `)
272
+ })
214
273
 
215
274
  test('missing components are ignored', () => {
216
275
  expect(
@@ -224,6 +283,7 @@ test('missing components are ignored', () => {
224
283
  "message": "Unsupported jsx component MissingComponent",
225
284
  },
226
285
  ],
286
+ "html": "",
227
287
  "result": <React.Fragment />,
228
288
  }
229
289
  `)
@@ -268,6 +328,7 @@ test('props parsing', () => {
268
328
  "message": "Expressions in jsx props are not supported (...{ spread: true })",
269
329
  },
270
330
  ],
331
+ "html": "<h1><p>hi</p></h1>",
271
332
  "result": <React.Fragment>
272
333
  <Heading
273
334
  backTick="some \${expr} value"
@@ -300,6 +361,7 @@ test('breaks', () => {
300
361
  ).toMatchInlineSnapshot(`
301
362
  {
302
363
  "errors": [],
364
+ "html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p>",
303
365
  "result": <React.Fragment>
304
366
  <p>
305
367
  To have a line break without a paragraph, you will need to use two trailing spaces.
@@ -342,7 +404,7 @@ test('kitchen sink', () => {
342
404
 
343
405
  ## Headers
344
406
 
345
- \`\`\`no-highlight
407
+
346
408
  # H1
347
409
  ## H2
348
410
  ### H3
@@ -357,7 +419,7 @@ test('kitchen sink', () => {
357
419
 
358
420
  Alt-H2
359
421
  ------
360
- \`\`\`
422
+
361
423
 
362
424
  # H1
363
425
  ## H2
@@ -735,6 +797,112 @@ test('kitchen sink', () => {
735
797
  "message": "Unsupported jsx component dl",
736
798
  },
737
799
  ],
800
+ "html": "<h1>Markdown Kitchen Sink</h1><p>This file is <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" title="">https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet</a> plus a few fixes and additions. Used by <a href="https://github.com/obedm503/bootmark" title="">obedm503/bootmark</a> to <a href="https://obedm503.github.io/bootmark/docs/markdown-cheatsheet.html" title="">demonstrate</a> it&#x27;s styling features.</p><p>This is intended as a quick reference and showcase. For more complete info, see <a href="http://daringfireball.net/projects/markdown/" title="">John Gruber&#x27;s original spec</a> and the <a href="http://github.github.com/github-flavored-markdown/" title="">Github-flavored Markdown info page</a>.</p><p>Note that there is also a <a href="./Markdown-Here-Cheatsheet" title="">Cheatsheet specific to Markdown Here</a> if that&#x27;s what you&#x27;re looking for. You can also check out <a href="./Other-Markdown-Tools" title="">more Markdown tools</a>.</p><h5>Table of Contents</h5><p><a href="#headers" title="">Headers</a><br/><a href="#emphasis" title="">Emphasis</a><br/><a href="#lists" title="">Lists</a><br/><a href="#links" title="">Links</a><br/><a href="#images" title="">Images</a><br/><a href="#code" title="">Code and Syntax Highlighting</a><br/><a href="#tables" title="">Tables</a><br/><a href="#blockquotes" title="">Blockquotes</a><br/><a href="#html" title="">Inline HTML</a><br/><a href="#hr" title="">Horizontal Rule</a><br/><a href="#lines" title="">Line Breaks</a><br/><a href="#videos" title="">YouTube Videos</a></p><a name="headers"></a><h2>Headers</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><a name="emphasis"></a><h2>Emphasis</h2><pre><code>Emphasis, aka italics, with *asterisks* or _underscores_.
801
+
802
+ Strong emphasis, aka bold, with **asterisks** or __underscores__.
803
+
804
+ Combined emphasis with **asterisks and _underscores_**.
805
+
806
+ Strikethrough uses two tildes. ~~Scratch this.~~</code></pre><p>Emphasis, aka italics, with <em>asterisks</em> or <em>underscores</em>.</p><p>Strong emphasis, aka bold, with <strong>asterisks</strong> or <strong>underscores</strong>.</p><p>Combined emphasis with <strong>asterisks and <em>underscores</em></strong>.</p><p>Strikethrough uses two tildes. <del>Scratch this.</del></p><a name="lists"></a><h2>Lists</h2><p>(In this example, leading and trailing spaces are shown with with dots: ⋅)</p><pre><code>1. First ordered list item
807
+ 2. Another item
808
+ ⋅⋅* Unordered sub-list.
809
+ 1. Actual numbers don&#x27;t matter, just that it&#x27;s a number
810
+ ⋅⋅1. Ordered sub-list
811
+ 4. And another item.
812
+
813
+ ⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we&#x27;ll use three here to also align the raw Markdown).
814
+
815
+ ⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
816
+ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
817
+ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
818
+
819
+ * Unordered list can use asterisks
820
+ - Or minuses
821
+ + Or pluses</code></pre><ol start="1"><li><p>First ordered list item</p></li><li><p>Another item</p></li></ol><ul><li><p>Unordered sub-list.</p></li></ul><ol start="1"><li><p>Actual numbers don&#x27;t matter, just that it&#x27;s a number</p></li><li><p>Ordered sub-list</p></li><li><p>And another item.</p><p>You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we&#x27;ll use three here to also align the raw Markdown).</p><p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p></li></ol><ul><li><p>Unordered list can use asterisks</p></li></ul><ul><li><p>Or minuses</p></li></ul><ul><li><p>Or pluses</p></li></ul><a name="links"></a><h2>Links</h2><p>There are two ways to create links.</p><pre><code>[I&#x27;m an inline-style link](https://www.google.com)
822
+
823
+ [I&#x27;m an inline-style link with title](https://www.google.com &quot;Google&#x27;s Homepage&quot;)
824
+
825
+ [I&#x27;m a reference-style link][Arbitrary case-insensitive reference text]
826
+
827
+ [I&#x27;m a relative reference to a repository file](../blob/master/LICENSE)
828
+
829
+ [You can use numbers for reference-style link definitions][1]
830
+
831
+ Or leave it empty and use the [link text itself].
832
+
833
+ URLs and URLs in angle brackets will automatically get turned into links.
834
+ http://www.example.com and sometimes
835
+ example.com (but not on Github, for example).
836
+
837
+ Some text to show that the reference links can follow later.
838
+
839
+ [arbitrary case-insensitive reference text]: https://www.mozilla.org
840
+ [1]: http://slashdot.org
841
+ [link text itself]: http://www.reddit.com</code></pre><p><a href="https://www.google.com" title="">I&#x27;m an inline-style link</a></p><p><a href="https://www.google.com" title="Google&#x27;s Homepage">I&#x27;m an inline-style link with title</a></p><p><a href="https://www.mozilla.org">I&#x27;m a reference-style link</a></p><p><a href="../blob/master/LICENSE" title="">I&#x27;m a relative reference to a repository file</a></p><p><a href="http://slashdot.org">You can use numbers for reference-style link definitions</a></p><p>Or leave it empty and use the <a href="http://www.reddit.com">link text itself</a>.</p><p>URLs and URLs in angle brackets will automatically get turned into links.
842
+ <a href="http://www.example.com" title="">http://www.example.com</a> and sometimes
843
+ example.com (but not on Github, for example).</p><p>Some text to show that the reference links can follow later.</p><a name="images"></a><h2>Images</h2><pre><code>Here&#x27;s our logo (hover to see the title text):
844
+
845
+ Inline-style:
846
+ ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png &quot;Logo Title Text 1&quot;)
847
+
848
+ Reference-style:
849
+ ![alt text][logo]
850
+
851
+ [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png &quot;Logo Title Text 2&quot;</code></pre><p>Here&#x27;s our logo (hover to see the title text):</p><p>Inline-style:
852
+ <img src="https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png" alt="alt text" title="Logo Title Text 1"/></p><p>Reference-style:
853
+ </p><a name="code"></a><h2>Code and Syntax Highlighting</h2><p>Code blocks are part of the Markdown spec, but syntax highlighting isn&#x27;t. However, many renderers -- like Github&#x27;s and <em>Markdown Here</em> -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. <em>Markdown Here</em> supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the <a href="http://softwaremaniacs.org/media/soft/highlight/test.html" title="">highlight.js demo page</a>.</p><pre><code>Inline \`code\` has \`back-ticks around\` it.</code></pre><p>Inline <code>code</code> has <code>back-ticks around</code> it.</p><p>Blocks of code are either fenced by lines with three back-ticks <code>\`\`\`</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they&#x27;re easier and only they support syntax highlighting.</p><pre><code>var s = &quot;JavaScript syntax highlighting&quot;;
854
+ alert(s);</code></pre><pre><code>s = &quot;Python syntax highlighting&quot;
855
+ print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
856
+ But let&#x27;s throw in a &amp;lt;b&amp;gt;tag&amp;lt;/b&amp;gt;.</code></pre><pre><code>var s = &quot;JavaScript syntax highlighting&quot;;
857
+ alert(s);</code></pre><pre><code>s = &quot;Python syntax highlighting&quot;
858
+ print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
859
+ But let&#x27;s throw in a &lt;b&gt;tag&lt;/b&gt;.</code></pre><a name="tables"></a><h2>Tables</h2><p>Tables aren&#x27;t part of the core Markdown spec, but they are part of GFM and <em>Markdown Here</em> supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.</p><pre><code>Colons can be used to align columns.
860
+
861
+ | Tables | Are | Cool |
862
+ | ------------- |:-------------:| -----:|
863
+ | col 3 is | right-aligned | $1600 |
864
+ | col 2 is | centered | $12 |
865
+ | zebra stripes | are neat | $1 |
866
+
867
+ There must be at least 3 dashes separating each header cell.
868
+ The outer pipes (|) are optional, and you don&#x27;t need to make the
869
+ raw Markdown line up prettily. You can also use inline Markdown.
870
+
871
+ Markdown | Less | Pretty
872
+ --- | --- | ---
873
+ *Still* | \`renders\` | **nicely**
874
+ 1 | 2 | 3</code></pre><p>Colons can be used to align columns.</p><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead><tbody><tr class=""><td class="">col 3 is</td><td class="">right-aligned</td><td class="">$1600</td></tr><tr class=""><td class="">col 2 is</td><td class="">centered</td><td class="">$12</td></tr><tr class=""><td class="">zebra stripes</td><td class="">are neat</td><td class="">$1</td></tr></tbody></table><p>There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don&#x27;t need to make the raw Markdown line up prettily. You can also use inline Markdown.</p><table><thead><tr class=""><td class="">Markdown</td><td class="">Less</td><td class="">Pretty</td></tr></thead><tbody><tr class=""><td class=""><em>Still</em></td><td class=""><code>renders</code></td><td class=""><strong>nicely</strong></td></tr><tr class=""><td class="">1</td><td class="">2</td><td class="">3</td></tr></tbody></table><a name="blockquotes"></a><h2>Blockquotes</h2><pre><code>&gt; Blockquotes are very handy in email to emulate reply text.
875
+ &gt; This line is part of the same quote.
876
+
877
+ Quote break.
878
+
879
+ &gt; This is a very long line that will still be quoted properly when it wraps. Oh boy let&#x27;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. </code></pre><blockquote><p>Blockquotes are very handy in email to emulate reply text.
880
+ This line is part of the same quote.</p></blockquote><p>Quote break.</p><blockquote><p>This is a very long line that will still be quoted properly when it wraps. Oh boy let&#x27;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can <em>put</em> <strong>Markdown</strong> into a blockquote.</p></blockquote><a name="html"></a><h2>Inline HTML</h2><p>You can also use raw HTML in your Markdown, and it&#x27;ll mostly work pretty well.</p><pre><code>&lt;dl&gt;
881
+ &lt;dt&gt;Definition list&lt;/dt&gt;
882
+ &lt;dd&gt;Is something people use sometimes.&lt;/dd&gt;
883
+
884
+ &lt;dt&gt;Markdown in HTML&lt;/dt&gt;
885
+ &lt;dd&gt;Does *not* work **very** well. Use HTML &lt;em&gt;tags&lt;/em&gt;.&lt;/dd&gt;
886
+ &lt;/dl&gt;</code></pre><a name="hr"></a><h2>Horizontal Rule</h2><pre><code>Three or more...
887
+
888
+ ---
889
+
890
+ Hyphens
891
+
892
+ ***
893
+
894
+ Asterisks
895
+
896
+ ___
897
+
898
+ Underscores</code></pre><p>Three or more...</p><hr/><p>Hyphens</p><hr/><p>Asterisks</p><hr/><p>Underscores</p><a name="lines"></a><h2>Line Breaks</h2><p>My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You&#x27;ll soon learn to get what you want. &quot;Markdown Toggle&quot; is your friend.</p><p>Here are some things to try out:</p><pre><code>Here&#x27;s a line for us to start with.
899
+
900
+ This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
901
+
902
+ This line is also a separate paragraph, but...
903
+ This line is only separated by a single newline, so it&#x27;s a separate line in the *same paragraph*.</code></pre><p>Here&#x27;s a line for us to start with.</p><p>This line is separated from the one above by two newlines, so it will be a <em>separate paragraph</em>.</p><p>This line is also begins a separate paragraph, but...<br/>This line is only separated by a single newline, so it&#x27;s a separate line in the <em>same paragraph</em>.</p><p>(Technical note: <em>Markdown Here</em> uses GFM line breaks, so there&#x27;s no need to use MD&#x27;s two-space line breaks.)</p><a name="videos"></a><h2>YouTube Videos</h2><p>They can&#x27;t be added directly but you can add an image with a link to the video like this:</p><pre><code>&lt;a href=&quot;http://www.youtube.com/watch?feature=player_embedded&amp;v=YOUTUBE_VIDEO_ID_HERE
904
+ &quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg&quot;
905
+ alt=&quot;IMAGE ALT TEXT HERE&quot; width=&quot;240&quot; height=&quot;180&quot; border=&quot;10&quot; /&gt;&lt;/a&gt;</code></pre><p>Or, in pure Markdown, but losing the image sizing and border:</p><pre><code>[![IMAGE ALT TEXT HERE](http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg)](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)</code></pre>",
738
906
  "result": <React.Fragment>
739
907
  <h1>
740
908
  Markdown Kitchen Sink
@@ -891,24 +1059,33 @@ test('kitchen sink', () => {
891
1059
  <h2>
892
1060
  Headers
893
1061
  </h2>
894
- <pre>
895
- <code>
896
- # H1
897
- ## H2
898
- ### H3
899
- #### H4
900
- ##### H5
901
- ###### H6
902
-
903
- Alternatively, for H1 and H2, an underline-ish style:
904
-
905
- Alt-H1
906
- ======
907
-
908
- Alt-H2
909
- ------
910
- </code>
911
- </pre>
1062
+ <h1>
1063
+ H1
1064
+ </h1>
1065
+ <h2>
1066
+ H2
1067
+ </h2>
1068
+ <h3>
1069
+ H3
1070
+ </h3>
1071
+ <h4>
1072
+ H4
1073
+ </h4>
1074
+ <h5>
1075
+ H5
1076
+ </h5>
1077
+ <h6>
1078
+ H6
1079
+ </h6>
1080
+ <p>
1081
+ Alternatively, for H1 and H2, an underline-ish style:
1082
+ </p>
1083
+ <h1>
1084
+ Alt-H1
1085
+ </h1>
1086
+ <h2>
1087
+ Alt-H2
1088
+ </h2>
912
1089
  <h1>
913
1090
  H1
914
1091
  </h1>
package/src/safe-mdx.tsx CHANGED
@@ -1,9 +1,9 @@
1
1
  import React, { cloneElement } from 'react'
2
2
  import { htmlToJsx } from 'html-to-jsx-transform'
3
- import { Node, Parent } from 'mdast'
3
+ import { Node, Parent, RootContent } from 'mdast'
4
4
  import remarkFrontmatter from 'remark-frontmatter'
5
5
 
6
- import { Root, RootContent } from 'mdast'
6
+ import { Root, Yaml } from 'mdast'
7
7
  import { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx'
8
8
  import { remark } from 'remark'
9
9
  import remarkGfm from 'remark-gfm'
@@ -67,6 +67,7 @@ const nativeTags = [
67
67
  'table',
68
68
  'tbody',
69
69
  'td',
70
+ 'tfoot',
70
71
  'th',
71
72
  'thead',
72
73
  'tr',
@@ -91,6 +92,7 @@ export class MdastToJsx {
91
92
  }) {
92
93
  this.str = code
93
94
  this.mdast = mdast || mdxParser.parse(code)
95
+
94
96
  this.c = {
95
97
  ...Object.fromEntries(
96
98
  nativeTags.map((tag) => {
@@ -105,7 +107,9 @@ export class MdastToJsx {
105
107
  ?.flatMap((child) => this.mdastTransformer(child))
106
108
  .filter(Boolean)
107
109
  if (Array.isArray(res)) {
108
- if (res.length === 1) {
110
+ if (!res.length) {
111
+ return null
112
+ } else if (res.length === 1) {
109
113
  return res[0]
110
114
  } else {
111
115
  return res.map((x, i) =>
@@ -120,7 +124,9 @@ export class MdastToJsx {
120
124
  ?.flatMap((child, i) => this.jsxTransformer(child))
121
125
  .filter(Boolean)
122
126
  if (Array.isArray(res)) {
123
- if (res.length === 1) {
127
+ if (!res.length) {
128
+ return null
129
+ } else if (res.length === 1) {
124
130
  return res[0]
125
131
  } else {
126
132
  return res.map((x, i) =>
@@ -224,7 +230,7 @@ export class MdastToJsx {
224
230
  case 'heading': {
225
231
  const level = node.depth
226
232
 
227
- const Tag: any = `h${level}`
233
+ const Tag = this.c[`h${level}`] ?? `h${level}`
228
234
  return <Tag>{this.mapMdastChildren(node)}</Tag>
229
235
  }
230
236
  case 'paragraph': {
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './safe-mdx';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './safe-mdx';
2
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './safe-mdx'