2.2.5 • Published 6 months ago

mnm-html-parser v2.2.5

Weekly downloads
17
License
ISC
Repository
-
Last release
6 months ago

The role of this module is to parse the valid html tags in a string and return an array of objects which has the following properties:

parsedResult : an array of objects, where in each item will have the value, type, and position as its properties,

  • each of the objects in the array will have the following properties :
    • value : the parsed substring,
    • type : the type of the string, whether its an html tag;
    • position : zero-based indexing determining the position of the substr in the array of objects

pairedTags : an array of the valid html tags parsed and paired; each item in the array will have openingTag and closingTag as its properties; and each will have the same properties as any item in the parsedResult;

  • each of the objects in the array will have the following properties :

    • opening

      • value : the parsed substring,
      • el : name of the valid element,
      • parsePosition : is the same as the position used in parsedResult; we can use this to reference where the paired tags sit in the string; or maybe return an innerHTML;
    • closing

      • value : the parsed substring,
      • el : name of the valid element,
      • parsePosition : is the same as the position used in parsedResult; we can use this to reference where the paired tags sit in the string; or maybe return an innerHTML;

selfClosingTags : this is just a similar array to the parsedResult; the only difference is that it is composed of only self-closing type of html;

  • each item will have the same properties as any item in the parsedResult;

removedInvalidTags : this is just a similar array to the parsedResult; initial value is an empty array; and depending on whether you want to remove the invalid tags or not, it will or will not have any array element;

  • each item will have the same properties as any item in the parsedResult;

Usage

    const htmlParser = require("mnm-html-parser");
    const parsedHtmlObject = htmlParser(htmlString);
    parsedHtmlObject.initialize();
    console.log(parsedHtmlObject); // returns parsedHtmlObject {parsedResult = [], pairedTags = [], selfClosingTags = [], removedInvalidTags = []}
2.2.5

6 months ago

2.2.4

3 years ago

2.2.3

3 years ago

2.2.1

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.0

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago