0.1.2 • Published 4 years ago
rehype-title-figure v0.1.2
rehype-title-figure
Rehype plugin that adds a caption using the title attribute of the img.
Install
$ yarn add rehype-title-figureor
$ npm i rehype-title-figureUsage
import unified from 'unified'
import remark from 'remark-parse'
import remark2rehype from 'remark-rehype'
import stringify from 'rehype-stringify'
import rehypeTitleFigure from 'rehype-title-figure'
function compile(md: string) {
  return unified()
    .use(remark)
    .use(remark2rehype)
    .use(rehypeTitleFigure)
    .use(stringify)
    .processSync(md)
    .toString()
}
const output = compile(
  ''
)
console.log(output)output:
<figure><img src="https://placehold.jp/150x150.png" alt="alt text" title="caption text"><figcaption>caption text</figcaption></figure>LICENSE
MIT © y-temp4