Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wataru-chocola/remark-definition-list
remark plugin to support definition list
https://github.com/wataru-chocola/remark-definition-list
Last synced: 14 days ago
JSON representation
remark plugin to support definition list
- Host: GitHub
- URL: https://github.com/wataru-chocola/remark-definition-list
- Owner: wataru-chocola
- License: mit
- Created: 2021-09-07T16:06:10.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-28T04:50:22.000Z (17 days ago)
- Last Synced: 2024-10-28T08:04:42.317Z (16 days ago)
- Language: TypeScript
- Size: 828 KB
- Stars: 32
- Watchers: 2
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# remark-definition-list
[![Node.js CI](https://github.com/wataru-chocola/remark-definition-list/actions/workflows/node.js.yml/badge.svg)](https://github.com/wataru-chocola/remark-definition-list/actions/workflows/node.js.yml)
[remark] plugin to support definition list
## Feature
* fully support [Definition Lists Syntax of php-markdown]
* work with [rehype] using [remark-rehype]
* shipped with types[Definition Lists Syntax of php-markdown]: https://michelf.ca/projects/php-markdown/extra/#def-list
[remark]: https://github.com/remarkjs/remark
[rehype]: https://github.com/rehypejs/rehype
[remark-rehype]: https://github.com/remarkjs/remark-rehype
[mdast-util-definition-list]: https://github.com/wataru-chocola/mdast-util-definition-list## Install
```console
$ npm install remark-definition-list
```## Use
### Markdown -> HTML
```typescript
import { remarkDefinitionList, defListHastHandlers } from 'remark-definition-list';
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
import rehypeStringify from 'rehype-stringify';const md = `
Test for defList.Apple
: Pomaceous fruit of plants of the genus Malus in
the family Rosaceae.Orange
: The fruit of an evergreen tree of the genus Citrus.
`;const html = await unified()
.use(remarkParse)
.use(remarkDefinitionList)
.use(remarkRehype, {
handlers: {
// any other handlers
...defListHastHandlers,
}
})
.use(rehypeStringify)
.process(md);
```### HTML -> Markdown
```typescript
import { remarkDefinitionList, defListHastToMdast } from 'remark-definition-list';
import { unified } from 'unified';import rehypeParse from 'rehype-parse';
import rehypeRemark from 'rehype-remark';
import remarkStringify from 'remark-stringify';const html = `
Test for defList.
- Apple
- Pomaceous fruit of plants of the genus Malus in
the family Rosaceae. - Orange
- The fruit of an evergreen tree of the genus Citrus.
const html2md = await unified()
.use(rehypeParse, { fragment: true })
.use(rehypeRemark, {
handlers: defListHastToMdast,
})
.use(remarkDefinitionList)
.use(remarkStringify)
.process(html);
```