tagser4js
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

Overview

Simple tag-based document parser. It is not about HTML parsing. You can use whatever tags you want.

Available types of tags:

  • Self closing tags: <tag [attributes]/>
  • Block tags: <tag [attributes]> Body

Attributes types:

  • bool: - will be converted to bordered='true'
  • with value: - value should be placed in single or double quotes

Usage

A simple usage example:

  const Tagser = require('tagser4js');
  var tagser = new Tagser();
  var html = '<hello> Hello bro </hello>';
  
  var list =  tagser.parse(html);
  
}

Notes

  • Tag names are case sensitive. Open and close tags in block tag declaration should have the same spelling
  • Attribute names are case sensitive: attribute A and attribute a are not the same

Restrictions

  • All self closing tags should have slash before closing bracket. Using <br> tag without slash will cause an error.
  • No spaces allowed between open bracket and tag name: < tag /> - will cause an error
  • No spaces allowed between slash and close bracket : <tag / > - will cause an error
  • No spaces allowed in attribute declaration:
  • <tag A = 'value' /> - error
  • <tag A= 'value' /> - error
  • <tag A ='value' /> - error

Options

You can pass options to the Tagser constructor or set them with setOption() method.

Available options:

  • ignoreCase - enables or disables case ignoring of opening and closing tag; false by default

Dependencies (3)

Dev Dependencies (6)

Package Sidebar

Install

npm i tagser4js

Weekly Downloads

8

Version

2.0.1

License

ISC

Unpacked Size

133 kB

Total Files

35

Last publish

Collaborators

  • yohanson555