Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tomeraberbach/remark-admonition

A remark plugin for rendering admonitions from directives.
https://github.com/tomeraberbach/remark-admonition

admonition callout markdown npm-module npm-package remark remark-plugin

Last synced: 3 months ago
JSON representation

A remark plugin for rendering admonitions from directives.

Awesome Lists containing this project

README

        


remark-admonition



version


CI


gzip size


brotli size


A remark plugin for rendering admonitions from directives.

## Install

```sh
$ npm i remark-admonition
```

## Usage

```js
import { DEFAULT_ADMONITION_TYPES, remarkAdmonition } from 'remark-admonition'
import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkDirective from 'remark-directive'
import remarkRehype from 'remark-rehype'
import rehypeStringify from 'rehype-stringify'

console.log(
unified()
.use(remarkParse)
.use(remarkDirective)
.use(remarkAdmonition, {
defaultElement: `section`,
defaultProperties: { 'data-admonish': `true` },
types: new Map([
...DEFAULT_ADMONITION_TYPES,
[
`fyi`,
{
defaultLabel: `FYI`,
element: `div`,
properties: { style: `color: blue;` },
},
],
]),
})
.use(remarkRehype)
.use(rehypeStringify).processSync(`
# Hello World!

:::note
Be careful folks!
:::

:::fyi[**title** time]
Wowowow!
:::
`),
)
```

Output:

```html

Hello World!

Be careful folks!


Wowowow!



```

Of course, instead of directly converting to HTML you can write a plugin that
processes the attributes added by this plugin.

## Contributing

Stars are always welcome!

For bugs and feature requests,
[please create an issue](https://github.com/TomerAberbach/remark-admonition/issues/new).

For pull requests, please read the
[contributing guidelines](https://github.com/TomerAberbach/remark-admonition/blob/main/contributing.md).

## License

[Apache License 2.0](https://github.com/TomerAberbach/remark-admonition/blob/main/license)

This is not an official Google product.