Render images occurring by itself in a paragraph as `<figure><img ...></figure>`, similar to pandoc's implicit_figures
npm install markdown-it-implicit-figuresRender images occurring by itself in a paragraph as , similar to pandoc's implicit figures.
Example input:
``md
text with 

works with links too:

`
Output: text with works with links too:
`html`


``
$ npm install --save markdown-it-implicit-figures
`js
var md = require('markdown-it')();
var implicitFigures = require('markdown-it-implicit-figures');
md.use(implicitFigures, {
dataType: false, //
figcaption: false, //
keepAlt: false //
lazyLoading: false, // , default: false
link: false //
, default: false
tabindex: false, //
});
var src = 'text with \n\n\n\nanother paragraph';
var res = md.render(src);
console.log(res);
`
- dataType: Set dataType to true to declare the data-type being wrapped,
e.g.: . This can be useful for applying specialfigcaption
styling for different kind of figures.
- : Set figcaption to true or alt to put the alternative text
in a -block after the image. E.g.: !text renders to
`html`

figcaption
- Set to title to put the title text in a -block!text
after the image. E.g.: renders to`
html`

keepAlt
- : Set keepAlt to true to prevent it from being cleared when turnedfigcaption
into a , E.g.: !text renders to
`html`

tabindex
- : Set tabindex to true to add a tabindex property to eachtabindex="1"
figure, beginning at and incrementing for each figurelazyLoading
encountered. Could be used with this css-trick,
which expands figures upon mouse-over.
- : Set lazyLoading to true to add loading="lazy" to image element.link
- : Put a link around the image if there is none yet.copyAttrs
- : Copy attributes matching (RegExp or string) copyAttrs to figure` element.
MIT © Arve Seljebu