simple-html-tokenizer

WebJar for simple-html-tokenizer

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

simple-html-tokenizer
Last Version

Last Version

0.5.7
Release Date

Release Date

Type

Type

jar
Description

Description

simple-html-tokenizer
WebJar for simple-html-tokenizer
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/tildeio/simple-html-tokenizer

Download simple-html-tokenizer

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/simple-html-tokenizer/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>simple-html-tokenizer</artifactId>
    <version>0.5.7</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/simple-html-tokenizer/
implementation 'org.webjars.npm:simple-html-tokenizer:0.5.7'
// https://jarcasting.com/artifacts/org.webjars.npm/simple-html-tokenizer/
implementation ("org.webjars.npm:simple-html-tokenizer:0.5.7")
'org.webjars.npm:simple-html-tokenizer:jar:0.5.7'
<dependency org="org.webjars.npm" name="simple-html-tokenizer" rev="0.5.7">
  <artifact name="simple-html-tokenizer" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='simple-html-tokenizer', version='0.5.7')
)
libraryDependencies += "org.webjars.npm" % "simple-html-tokenizer" % "0.5.7"
[org.webjars.npm/simple-html-tokenizer "0.5.7"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Simple HTML Tokenizer Build Status

Simple HTML Tokenizer is a lightweight JavaScript library that can be used to tokenize the kind of HTML normally found in templates. It can be used to preprocess templates to change the behavior of some template element depending upon whether the template element was found in an attribute or text.

It is not a full HTML5 tokenizer. It focuses on the kind of HTML that is used in templates: content designed to be inserted into the <body> and without <script> tags.

In particular, Simple HTML Tokenizer does not handle many states from the HTML5 Tokenizer Specification:

  • Any states involving CDATA or RCDATA
  • Any states involving <script>
  • Any states involving <DOCTYPE>
  • The bogus comment state

It also passes through character references, instead of trying to tokenize and process them, because the preprocessed templates will ultimately be parsed by a real browser context.

At the moment, there are some error states specified by the tokenizer spec that are not handled by Simple HTML Tokenizer. Ultimately, I plan to support all error states, as well as provide information about tokenizer errors in debug mode.

Usage

You can tokenize HTML:

var tokens = HTML5Tokenizer.tokenize("<div id='foo' href=bar class=\"bat\">");

var token = tokens[0];
token.tagName     //=> "div"
token.attributes  //=> [["id", "foo"], ["href", "bar"], ["class", "bat"]]
token.selfClosing //=> false

Building and running the tests

npm install
npm test
org.webjars.npm

Tilde

Versions

Version
0.5.7
0.5.6
0.5.1
0.2.5
0.1.1