UNPKG

gatsby-remark-image-attributes

Version:

Creates HTML image markup with style and data-* attributes from [`mdAST Image`](https://github.com/syntax-tree/mdast#image) nodes with attributes in their title.

22 lines (21 loc) 797 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const _1 = __importDefault(require("./")); class WrappedAttributeImage extends _1.default { constructor(node) { super(node); } get html() { this.sanitizeTitle().applyDataAttributes(); return `<span class="gatsby-img-attributes" style="display:${this.attributes.inline ? 'inline-block' : 'block'}; ${this.style}">${this.node.value}</span>`; } static test(node) { return (!!node.url && /<img/.test(node.value) && _1.default.hasAttributes(node.title || '')); } } exports.default = WrappedAttributeImage;