Socket
Socket
Sign inDemoInstall

markdown-it-implicit-figures

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-implicit-figures - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

68

index.js

@@ -60,18 +60,66 @@ 'use strict';

if (options.figcaption == true) {
if (image.children && image.children.length) {
token.children.push(
new state.Token('figcaption_open', 'figcaption', 1)
if (options.figcaption) {
// store string value of option for later comparison
var captionOptionString = new String(options.figcaption).toLowerCase().trim();
if (captionOptionString == 'title') {
var figCaption;
var captionObj = image.attrs.find(function ([k]) {
return k === 'title';
});
if (Array.isArray(captionObj)) {
figCaption = captionObj[1];
}
if (figCaption) {
var captionArray = md.parseInline(figCaption);
// use empty default
var captionContent = { children: []};
// override if the data is there
if (Array.isArray(captionArray) && captionArray.length) {
captionContent = captionArray[0];
}
// add figcaption
token.children.push(
new state.Token('figcaption_open', 'figcaption', 1)
);
token.children.splice(token.children.length, 0, ...image.children);
token.children.push(
new state.Token('figcaption_close', 'figcaption', -1)
token.children.push(...captionContent.children);
token.children.push(
new state.Token('figcaption_close', 'figcaption', -1)
);
image.children.length = 0;
if (image.attrs) {
image.attrs = image.attrs.filter(function ([k]) {
return k !== 'title';
});
}
}
}
else if (options.figcaption == true || captionOptionString == 'alt') {
if (image.children && image.children.length) {
token.children.push(
new state.Token('figcaption_open', 'figcaption', 1)
);
token.children.splice(token.children.length, 0, ...image.children);
token.children.push(
new state.Token('figcaption_close', 'figcaption', -1)
);
if (!options.keepAlt) image.children.length = 0;
}
}
}
if (options.copyAttrs && image.attrs) {
const f = options.copyAttrs === true ? '' : options.copyAttrs
figure.attrs = image.attrs.filter(([k,v]) => k.match(f))
var f = options.copyAttrs === true ? '' : options.copyAttrs;
figure.attrs = image.attrs.filter(function ([k]) {
return k.match(f);
});
}

@@ -78,0 +126,0 @@

2

package.json
{
"name": "markdown-it-implicit-figures",
"version": "0.11.0",
"version": "0.12.0",
"description": "Render images occurring by itself in a paragraph as `<figure><img ...></figure>`, similar to pandoc's implicit_figures",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -41,5 +41,6 @@ # markdown-it-implicit-figures [![Build Status](https://travis-ci.org/arve0/markdown-it-implicit-figures.svg?branch=master)](https://travis-ci.org/arve0/markdown-it-implicit-figures) [![npm version](https://badge.fury.io/js/markdown-it-implicit-figures.svg)](http://badge.fury.io/js/markdown-it-implicit-figures)

figcaption: false, // <figcaption>alternative text</figcaption>, default: false
tabindex: false, // <figure tabindex="1+n">..., default: false
keepAlt: false // <img alt="alt text" .../><figcaption>alt text</figcaption>, default: false
lazyLoading: false, // <img loading="lazy" ...>, default: false
link: false // <a href="img.png"><img src="img.png"></a>, default: false
tabindex: false, // <figure tabindex="1+n">..., default: false
});

@@ -60,4 +61,4 @@

styling for different kind of figures.
- `figcaption`: Set `figcaption` to `true` to put the alternative text in a
`<figcaption>`-block after the image. E.g.: `![text](img.png)` renders to
- `figcaption`: Set `figcaption` to `true` or `alt` to put the alternative text
in a `<figcaption>`-block after the image. E.g.: `![text](img.png)` renders to

@@ -70,2 +71,19 @@ ```html

```
- Set `figcaption` to `title` to put the title text in a `<figcaption>`-block
after the image. E.g.: `![text](img.png "title")` renders to
```html
<figure>
<img src="img.png" alt="text">
<figcaption>title</figcaption>
</figure>
```
- `keepAlt`: Set `keepAlt` to `true` to prevent it from being cleared when turned
into a `figcaption`, E.g.: `![text](img.png)` renders to
```html
<figure>
<img src="img.png" alt="text">
<figcaption>text</figcaption>
</figure>
```
- `tabindex`: Set `tabindex` to `true` to add a `tabindex` property to each

@@ -72,0 +90,0 @@ figure, beginning at `tabindex="1"` and incrementing for each figure

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc