UNPKG

soames-gatsby-theme

Version:

A customizable Gatsby theme for personal websites using WordPress as a headless CMS.

19 lines (18 loc) 629 B
"use strict"; // src/utils/shortcodes/getAttributes.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.getAttributes = getAttributes; function getAttributes(match) { if (!match || !match[1]) return null; const attributes = {}; const attrString = match[1]; const regex = /(\w+)=["']?((?:.(?!["']?\s+(?:\S+)=|\s*\/?[>"']))+.)["']?/g; let attrMatch; while ((attrMatch = regex.exec(attrString)) !== null) { const key = attrMatch[1]; const value = attrMatch[2].replace(/[″”]+/g, '').split(','); attributes[key] = value; } return attributes; }