makestatic-parse-html

1.1.16 • Public • Published

Parse HTML

Parse HTML files to an AST

Parses HTML output files to an abstract syntax tree.



Install

yarn add makestatic-parse-html

API

ParseHtml

Parses HTML files to abstract syntax trees.

See Also

.sources

ParseHtml.prototype.sources(file, context[, options])

Parse a file to an abstract syntax tree, the AST is assigned to file.ast.html.

This implementation assigns a seal function to the file so that when the file content is updated it will correspond to the current state of the AST.

The generated AST is decorated with querySelector and querySelectorAll functions so that you can query the AST for desired nodes.

It also adds an adapter getter that allows access to the static DOM adapter function.

  • file Object the current file.
  • context Object the processing context.
  • options Object options for postcss.

#getAttribute

static getAttribute(el, name[, value])

Utility to get an attribute from a node.

Iterates the attribute list and gets the first attribute that has the given name and optionally a specific value.

Note this is an extension to the interface required by css-select.

Returns the attribute or undefined.

  • el Object the node.
  • name String the attribute name.
  • value String the attribute value.

License

MIT


Created by mkdoc on March 12, 2017

Package Sidebar

Install

npm i makestatic-parse-html

Weekly Downloads

3

Version

1.1.16

License

MIT

Last publish

Collaborators

  • muji
  • tmpfs