UNPKG

2.83 kBMarkdownView Raw
1<img align="right" width="26%" src="https://owlbert.io/images/owlberts-png/Reading.psd.png">
2
3@readme/markdown
4===
5
6ReadMe's flavored Markdown parser and MDX rendering engine. ![CI Status](https://github.com/readmeio/markdown/workflows/CI/badge.svg)
7
8```
9npm install --save @readme/markdown
10```
11
12## Usage
13
14By default, the updated markdown package exports a function which takes a string of [ReadMe-flavored markdown](https://docs.readme.com/rdmd/docs/syntax-extensions) and returns a tree of React components:
15
16```jsx
17import React from 'react';
18import rdmd from "@readme/markdown";
19
20export default ({ body }) => (
21 <div className="markdown-body">
22 {rdmd(body)}
23 </div>
24);
25```
26
27### Export Methods
28
29In addition to the default React processor, the package exports some other methods for transforming ReadMe-flavored markdown:
30
31| Export | Description | Arguments |
32| -------:|:---------------------------------------------- |:--------------- |
33|*`react`*|_(default)_ returns a VDOM tree object |`text`, `options`|
34|*`md`* | transform mdast in to ReadMe-flavored markdown |`tree`, `options`|
35|*`html`* | transform markdown in to HTML |`text`, `options`|
36|*`mdast`*| transform markdown to an mdast object |`text`, `options`|
37|*`hast`* | transform markdown to HAST object |`text`, `options`|
38|*`plain`*| transform markdown to plain text |`text`, `options`|
39|*`utils`*| contexts, defaults, helpers, etc. | N/A |
40
41### Settings & Options
42
43Each processor method takes an options object which you can use to adjust the output HTML or React tree. These options include:
44
45- **`compatibilityMode`** — Enable [compatibility features](https://github.com/readmeio/api-explorer/issues/668) from our old markdown engine.
46- **`copyButtons`** — Automatically insert a button to copy a block of text to the clipboard. Currently used on `<code>` elements.
47- **`correctnewlines`** — Render new line delimeters as `<br>` tags.
48- **`markdownOptions`** — Remark [parser options](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#processorusestringify-options).
49
50## Flavored Syntax
51
52Our old editor rendered "Magic Block" components from a custom, JSON-based syntax. To provide seamless backwards-compatibility, our new processor ships with built in support for parsing this old format, and transpiles it straight in to our new, flavored Markdown.
53
54We've also sprinkled a bit of our own syntactic sugar on top to let you supercharge your docs. [**Learn more about ReadMe's flavored syntax!**](https://docs.readme.com/rdmd/docs/syntax-extensions)
55
56## Credits
57
58- **Lisence**: MIT
59- **Authors**: [Dom Harrington](https://github.com/domharrington/), [Rafe Goldberg](https://github.com/rafegoldberg)