Rehype plugin that adds a caption using the title attribute of the img.
npm install rehype-title-figure




Rehype plugin that adds a caption using the title attribute of the img.
``bash`
$ yarn add rehype-title-figure
or
`bash`
$ npm i rehype-title-figure
`ts
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(
'!alt text'
)
console.log(output)
`
output:
`html``
MIT © y-temp4