Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haraldrudell/tagfinder
Tagfinder parses html5 markup for opening tags and their attributes by Harald Rudell
https://github.com/haraldrudell/tagfinder
Last synced: 1 day ago
JSON representation
Tagfinder parses html5 markup for opening tags and their attributes by Harald Rudell
- Host: GitHub
- URL: https://github.com/haraldrudell/tagfinder
- Owner: haraldrudell
- Created: 2012-08-01T01:50:40.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-09-03T07:33:14.000Z (about 12 years ago)
- Last Synced: 2024-11-07T09:49:39.210Z (11 days ago)
- Language: JavaScript
- Homepage:
- Size: 125 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Tagfinder
Tagfinder parses html5 markup for opening tags and their attributes.
It can be used to parse html5 when other parsers or jQuery might be too slow, for example in a Web server. Tagfinder is the inner workings of the Webfiller module that facilitates dual-side rendering with Express or any node.js environment.
* [Tagfinder](https://github.com/haraldrudell/tagfinder) is on github
* [Webfiller](https://github.com/haraldrudell/webfiller) is on github# Usage Example
Example of JavaScript executed in node:
```js
console.log(require('tagfinder').decomposeHtml(
'x'))```
This will print:
```
{ pieces:
[ '',
'',
'x',
'' ],
tags: [ { t: 'title', i: 1, a: [Object], c: [Object] } ] }
```* .tags: an array of each opening element in the html
* .t the tagname text, like 'div' or 'html'
* .i the index in the contents array for this tag
* .v optional boolean: evaluates to true if this is a self-terminated void tag, eg.
* .a object: key: attribute name, value: string attribute value, classes are not present here
* .c classes array: the class attribute value split into an array of words* pieces array: the html markup split into many shorter strings
The document is split into an array of:
* One initial piece containing markup before any opening tag
* For each found opening tag, 3 elements:* The tag itself eg. ``
* Element contents up to the first opening tag, closing tag,or cdata segment
* The rest of the element contents, eg. `text`# Html5
Tagfinder is designed for html5. Carefully crafted html5 renders in most browsers. Tagfinder is not designed for older markup or xml. This means your markup needs to be html5, and as such it can target most browsers.
Tagfinder is designed for node.js, but could easily run in any JavaScript environment.
# Notes
© [Harald Rudell](http://www.haraldrudell.com) wrote this module in August, 2012
No warranty expressed or implied. Use at your own risk.
Please suggest better ways, new features and possible difficulties on [github](https://github.com/haraldrudell/tagfinder)