JSPM

rehype-title-figure

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1088
  • Score
    100M100P100Q113641F
  • License MIT

Rehype plugin that adds a caption using the title attribute of the img.

Package Exports

  • rehype-title-figure
  • rehype-title-figure/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rehype-title-figure) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

rehype-title-figure

main codecov npm version Conventional Commits code style: prettier

Rehype plugin that adds a caption using the title attribute of the img.

Install

$ yarn add rehype-title-figure

or

$ npm i rehype-title-figure

Usage

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](https://placehold.jp/150x150.png "caption text")'
)
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