Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hiro08gh/rich-editor-to-markdown-parser
microCMS Rich Editor response convert to markdown.
https://github.com/hiro08gh/rich-editor-to-markdown-parser
markdown markdown-parser microcms parser
Last synced: 20 days ago
JSON representation
microCMS Rich Editor response convert to markdown.
- Host: GitHub
- URL: https://github.com/hiro08gh/rich-editor-to-markdown-parser
- Owner: hiro08gh
- License: mit
- Created: 2023-12-07T08:56:11.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-10-21T03:20:46.000Z (26 days ago)
- Last Synced: 2024-10-21T06:22:31.363Z (26 days ago)
- Topics: markdown, markdown-parser, microcms, parser
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/rich-editor-to-markdown-parser
- Size: 488 KB
- Stars: 22
- Watchers: 1
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rich-editor-to-markdown-parser
Convert microCMS Rich Editor response to Markdown.
## Installation
```
npm install rich-editor-to-markdown-parser
```## Usage
```js
import { parser } from 'rich-editor-to-markdown-parser';
// If you are importing multiple items with the same name parser, please assign an alias to them.
import { parser as RichEditorToMarkddownParser } from 'rich-editor-to-markdown-parser';const html = '
Hello World!
This html string is convertinto markdown.
'parser(html); // # Hello World!\n\nThis **html** string is ~~convert~~ into [markdown.](https://exampe.com)
```※ Unsupported HTML tags are parsed as strings. When converting markdown to HTML, consider sanitizing it using [DOMPurify](https://github.com/cure53/DOMPurify) or [sanitize-html](https://github.com/apostrophecms/sanitize-html).
## HTML list| HTML | Description |
| --- | --- |
| Heading | |
| Bold | |
| Italic | |
| Underline | Parsed with HTML tags |
| Strike | |
| Code | |
| TextAlign | Not supported |
| Horizontal Rule | |
| Blockquote | |
| CodeBlock | |
| Table | |
| ListBullet | |
| ListOrdered | |
| Link | |
| Image | |
| Embed | Not supported |
| Custom class | Parsed with HTML tags |## Options
| Option | Description | Defualt |
| --- | --- | --- |
| image.size | Contain width and height image size. ex) ?w=1200&h=630 | true |
| image.query | Add image query in markdown. ex) ?format=webp | '' |
| markStyle.strong | ** or __ | ** |
| markStyle.em | * or _ | * |
| markStyle.li | - or * or + | - |
| markStyle.hr | --- or *** or ___ | --- |
| markStyle.pre | ``` or ~~~ | ``` |## Development
First, install npm dependencies.
```bash
npm install
```Running unit test. This library uses vitest.
```bash
npm run test
```Build modules.
```bash
npm run build
```## License
MIT License.© [hiro08gh](https://github.com/hiro08gh)