Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjosephprice committed Jan 23, 2024
2 parents 167657b + 98789f1 commit 6ed415a
Show file tree
Hide file tree
Showing 15 changed files with 3,805 additions and 20 deletions.
30 changes: 13 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@readme/markdown
===
# @readme/markdown

<img align="right" width="26%" src="https://owlbertsio-resized.s3.amazonaws.com/Reading.psd.full.png">

ReadMe's flavored Markdown parser and MDX rendering engine. <img align=center src=https://github.com/readmeio/markdown/workflows/CI/badge.svg alt="RDMD CI Status">
Expand All @@ -14,28 +14,24 @@ By default, the updated markdown package exports a function which takes a string

```jsx
import React from 'react';
import rdmd from "@readme/markdown";
import rdmd from '@readme/markdown';

export default ({ body }) => (
<div className="markdown-body">
{rdmd(body)}
</div>
);
export default ({ body }) => <div className="markdown-body">{rdmd(body)}</div>;
```

### Export Methods

In addition to the default React processor, the package exports some other methods for transforming ReadMe-flavored markdown:

| Export | Description | Arguments |
| -------:|:---------------------------------------------- |:--------------- |
|*`react`*|_(default)_ returns a VDOM tree object |`text`, `options`|
|*`md`* | transform mdast in to ReadMe-flavored markdown |`tree`, `options`|
|*`html`* | transform markdown in to HTML |`text`, `options`|
|*`mdast`*| transform markdown to an mdast object |`text`, `options`|
|*`hast`* | transform markdown to HAST object |`text`, `options`|
|*`plain`*| transform markdown to plain text |`text`, `options`|
|*`utils`*| contexts, defaults, helpers, etc. | N/A |
| Export | Description | Arguments |
| --------: | :--------------------------------------------- | :---------------- |
| _`react`_ | _(default)_ returns a VDOM tree object | `text`, `options` |
| _`md`_ | transform mdast in to ReadMe-flavored markdown | `tree`, `options` |
| _`html`_ | transform markdown in to HTML | `text`, `options` |
| _`mdast`_ | transform markdown to an mdast object | `text`, `options` |
| _`hast`_ | transform markdown to HAST object | `text`, `options` |
| _`plain`_ | transform markdown to plain text | `text`, `options` |
| _`utils`_ | contexts, defaults, helpers, etc. | N/A |

### Settings & Options

Expand Down
228 changes: 228 additions & 0 deletions __tests__/__snapshots__/disabling-tokenizers.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,51 @@ Object {
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 12,
"line": 1,
"offset": 11,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "# heading 1",
},
],
"position": Position {
"end": Object {
"column": 12,
"line": 1,
"offset": 11,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 2,
"line": 3,
"offset": 14,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;
Expand All @@ -23,13 +61,51 @@ Object {
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 18,
"line": 1,
"offset": 17,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "~~strikethrough~~",
},
],
"position": Position {
"end": Object {
"column": 18,
"line": 1,
"offset": 17,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 2,
"line": 3,
"offset": 20,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;
Expand All @@ -40,13 +116,51 @@ Object {
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 31,
"line": 1,
"offset": 30,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "*emphatic **strong** emphatic*",
},
],
"position": Position {
"end": Object {
"column": 31,
"line": 1,
"offset": 30,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 2,
"line": 3,
"offset": 33,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;
Expand All @@ -57,13 +171,51 @@ Object {
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 19,
"line": 1,
"offset": 18,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "\`const js = true \`",
},
],
"position": Position {
"end": Object {
"column": 19,
"line": 1,
"offset": 18,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 2,
"line": 3,
"offset": 21,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;
Expand All @@ -74,13 +226,51 @@ Object {
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 12,
"line": 1,
"offset": 11,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "# heading 1",
},
],
"position": Position {
"end": Object {
"column": 12,
"line": 1,
"offset": 11,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 2,
"line": 3,
"offset": 14,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;
Expand All @@ -91,13 +281,51 @@ Object {
Object {
"children": Array [
Object {
"position": Position {
"end": Object {
"column": 18,
"line": 1,
"offset": 17,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "text",
"value": "\`const js = true\`",
},
],
"position": Position {
"end": Object {
"column": 18,
"line": 1,
"offset": 17,
},
"indent": Array [],
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "paragraph",
},
],
"position": Object {
"end": Object {
"column": 2,
"line": 3,
"offset": 20,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;
27 changes: 27 additions & 0 deletions __tests__/__snapshots__/html-block-parser.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,38 @@ Object {
"children": Array [
Object {
"block": true,
"position": Position {
"end": Object {
"column": 5,
"line": 3,
"offset": 32,
},
"indent": Array [
1,
],
"start": Object {
"column": 1,
"line": 2,
"offset": 1,
},
},
"type": "html",
"value": "<div>Some block html</div>
",
},
],
"position": Object {
"end": Object {
"column": 2,
"line": 5,
"offset": 35,
},
"start": Object {
"column": 1,
"line": 1,
"offset": 0,
},
},
"type": "root",
}
`;
Loading

0 comments on commit 6ed415a

Please sign in to comment.