Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
dogma-html-parser
Advanced tools
HTML parser and compiler.
To parse an HTML string into an AST you can do the following:
import {parse} from 'dogma-html-parser'
const html = '<div class="test">Foo bar</div>'
const ast = parse(html)
The above example will set the constant ast to the following AST:
{
"attributes": {
"class": "test"
},
"children": [
{
"text": "Foo bar",
"type": "text"
}
],
"name": "div",
"type": "element"
}
It is worth noting the parser tries to be forgiving in terms of invalid whitespace, and by default will strip out unnecessary whitespace that doesn't actually get rendered by browsers. For example if you parse then compile the following:
< div > Test < /div >
You'll end up with:
<div>Test</div>
The compiler simply takes an AST and converts it to an HTML string like so:
import {compile} from 'dogma-html-parser'
const ast = {
attributes: {
'class': 'test',
},
children: [
{
text: 'Foo bar',
type: 'text',
},
],
name: 'div',
type: 'element',
}
const html = compile(ast)
The above example will set the constant html to the following HTML string:
<div class="test">Foo bar</div>
FAQs
HTML parser and compiler
The npm package dogma-html-parser receives a total of 1 weekly downloads. As such, dogma-html-parser popularity was classified as not popular.
We found that dogma-html-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.