Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paperist/remark-caption
wooorm/remark plugin for caption
https://github.com/paperist/remark-caption
Last synced: 23 days ago
JSON representation
wooorm/remark plugin for caption
- Host: GitHub
- URL: https://github.com/paperist/remark-caption
- Owner: Paperist
- License: mit
- Created: 2016-11-26T09:43:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T00:12:23.000Z (over 1 year ago)
- Last Synced: 2024-10-22T22:17:38.276Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 116 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @paperist/remark-caption
[![LICENSE][license-badge]][license]
[![NPM][npm-badge]][npm]
[![standard-readme compliant][standard-readme-badge]][standard-readme][npm]: https://www.npmjs.com/package/@paperist/remark-caption
[license]: https://3846masa.mit-license.org
[standard-readme]: https://github.com/RichardLitt/standard-readme
[npm-badge]: https://flat.badgen.net/npm/v/@paperist/remark-caption
[license-badge]: https://flat.badgen.net/badge/license/MIT/blue
[standard-readme-badge]: https://flat.badgen.net/badge/standard-readme/OK/green> [wooorm/remark] plugin for caption
Support [Pandoc's table / code caption][table-caption] at wooorm/remark.
[wooorm/remark]: https://github.com/wooorm/remark
[table-caption]: http://pandoc.org/MANUAL.html#extension-table_captions## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [AST](#ast)
- [`CaptionBlock`](#captionblock)
- [Contribute](#contribute)
- [License](#license)## Install
```
npm i remark @paperist/remark-caption
```## Usage
```js
const unified = require('unified');
const parser = require('remark-parse');
const tableCaption = require('@paperist/remark-caption');const markdown = `
| Right | Left | Default | Center |
|------:|:-----|---------|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |Table: Demonstration of pipe table syntax.
~~~rb
puts "Hello World!";
~~~Code: Hello World written by Ruby.
`;const processor = unified()
.use(parser)
.use(tableCaption);
const ast = processor.parse(markdown);processor.run(ast).then((ast) => {
console.dir(ast, { depth: null });
});
```## AST
See also [mdast], [unist].
[mdast]: https://github.com/syntax-tree/mdast
[unist]: https://github.com/syntax-tree/unist### `CaptionBlock`
`CaptionBlock` extends [`Parent`][unist-parent].
```typescript
interface CaptionBlock extends Parent {
type: 'captionBlock';
}
```For example, the following markdown:
```md
Table: Caption {#tbl:label}
```Yields:
```json
{
"type": "captionBlock",
"children": [
{
"type": "text",
"value": "Caption {#tbl:lable}"
}
]
}
```[unist-parent]: https://github.com/syntax-tree/unist#parent
## Contribute
PRs accepted.
## License
[MIT (c) 3846masa](https://3846masa.mit-license.org)