@xmark/transform-class-extension

0.24.0 • Public • Published

@xmark/transform-class-extension

xmark plugin to transform nodes with certain class in hast

Usage

yarn add @xmark/core @xmark/transform-class-extension
const inspect = require('unist-util-inspect');
const XMark = require('@xmark/core');
const plugin = require('@xmark/transform-class-extension');

const xmark = XMark();
xmark.useTransform(plugin, {
  extensions: {
    '.action-button': { propertyPath: 'tagName', value: 'action-button' },
    '.mui-paper': { propertyPath: 'tagName', value: 'mui-paper' },
    '.mui-grid-item': { propertyPath: 'tagName', value: 'mui-grid-item' },
    '.mui-grid-container': { propertyPath: 'tagName', value: 'mui-grid-container' },
    '.contact-form': { propertyPath: 'tagName', value: 'contact-form' },
  },
});

const markdown = `[Link](https://www.arcblock.io){.action-button}`;
const hast = xmark.toHAST(markdown);
console.log(inspect(hast));

will output:

root[1] [data={"quirksMode":false}]
└─ element[1] (1:1-1:48, 0-47) [tagName="p"]
    └─ element[1] (1:1-1:48, 0-47) [tagName="action-button"][properties={"href":"https://www.arcblock.io","className":["action-button"]}]
      └─ text: "Link" (1:2-1:6, 1-5)

Readme

Keywords

Package Sidebar

Install

npm i @xmark/transform-class-extension

Weekly Downloads

2

Version

0.24.0

License

MIT

Unpacked Size

3.04 kB

Total Files

3

Last publish

Collaborators

  • mave99a
  • wangshijun