1.0.1 • Published 2 years ago

@sika7/silver-html v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

License: MIT

@sika7/silver-html

this package is Can be recursively deleted or modified. for CommentNode and TextNode and ElementNode.

Usage

Step 1: Install plugin:

npm install --save @sika7/silver-html

Step 2: add a functions or plugin.

use example more

import { silverHtml } from '@sika7/silver-html'

const plugin = {
  pluginName: "devToMain",
  ElementNode: [
    {
      name: "all change tag for main",
      function: (element) => {
        element.tagName = "main";
        return element;
      },
    },
  ],
}
const result = silverHtml("<div>test</div>", {}, [plugin]);
console.log(result)
# <main>test</main>

plugin

plugin config.

const plugin = {
  pluginName: 'pluginName'; // required.
  ElementNode?: (node, level)    => node | null;
  CommentNode?: (comment, level) => node | null;
  TextNode?: (text, level)       => node | null;
}
settingdescription
pluginNameplugin name.
ElementNodeWhen creating recursive processing of elements
CommentNodeWhen creating recursive processing of comment
TextNodeWhen creating recursive processing of text