How to use simple-html-tokenizer - 10 common examples

To help you get started, we’ve selected a few simple-html-tokenizer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tildeio / simple-html-tokenizer / tests / tokenizer-tests.ts View on Github external
QUnit.test('A tag with a double-quoted empty', function(assert) {
  let tokens = tokenize('<div id="">');
  assert.deepEqual(tokens, [startTag('div', [['id', '', true]])]);
});
</div>
github tildeio / simple-html-tokenizer / tests / tokenizer-tests.ts View on Github external
QUnit.test('tokens: Chars start-tag Chars', function(assert) {
  let tokens = tokenize('Chars<div>Chars', { loc: true });
  assert.deepEqual(tokens, [
    locInfo(chars('Chars'), 1, 0, 1, 5),
    locInfo(startTag('div'), 1, 5, 1, 10),
    locInfo(chars('Chars'), 1, 10, 1, 15)
  ]);
});
</div>
github tildeio / simple-html-tokenizer / tests / tokenizer-tests.ts View on Github external
QUnit.test('A tag with a double-quoted attribute', function(assert) {
  let tokens = tokenize('<div id="foo">');
  assert.deepEqual(tokens, [startTag('div', [['id', 'foo', true]])]);
});
</div>
github tildeio / simple-html-tokenizer / tests / tokenizer-tests.ts View on Github external
QUnit.test('tokens: comment start-tag Chars end-tag', function(assert) {
  let tokens = tokenize(
    '<div>Chars\n</div>',
    { loc: true }
  );
  assert.deepEqual(tokens, [
    locInfo(comment(' multline\ncomment '), 1, 0, 2, 11),
    locInfo(startTag('div', [['foo', 'bar', false]]), 2, 11, 2, 24),
    locInfo(chars('Chars\n'), 2, 24, 3, 0),
    locInfo(endTag('div'), 3, 0, 3, 6)
  ]);
});
github tildeio / simple-html-tokenizer / tests / tokenizer-tests.ts View on Github external
QUnit.test('A newline immediately following a <textarea> tag is stripped', function(assert) {
  let tokens = tokenize("&lt;textarea&gt;\nhello</textarea>");
  assert.deepEqual(tokens, [startTag('textarea'), chars('hello'), endTag('textarea')]);
});
github tildeio / simple-html-tokenizer / tests / tokenizer-tests.ts View on Github external
QUnit.test('A self-closing tag', function(assert) {
  let tokens = tokenize('<img>');
  assert.deepEqual(tokens, [startTag('img', [], true)]);
});
github tildeio / simple-html-tokenizer / tests / tokenizer-tests.ts View on Github external
QUnit.test('A tag with capitalization in attributes', function(assert) {
  let tokens = tokenize('<svg viewBox="0 0 0 0">');
  assert.deepEqual(tokens, [startTag('svg', [['viewBox', '0 0 0 0', true]])]);
});
</svg>
github tildeio / simple-html-tokenizer / tests / tokenizer-tests.ts View on Github external
QUnit.test('A newline immediately following a <pre> tag is stripped', function(assert) {
  let tokens = tokenize("<pre>\nhello</pre>");
  assert.deepEqual(tokens, [startTag('pre'), chars('hello'), endTag('pre')]);
});
</pre>
github tildeio / simple-html-tokenizer / tests / tokenizer-tests.ts View on Github external
QUnit.test('A newline immediately following a <pre> tag is stripped', function(assert) {
  let tokens = tokenize("<pre>\nhello</pre>");
  assert.deepEqual(tokens, [startTag('PRE'), chars('hello'), endTag('PRE')]);
});
</pre>
github emberjs / ember.js / packages / internal-test-helpers / lib / equal-tokens.js View on Github external
function generateTokens(containerOrHTML) {
  if (typeof containerOrHTML === 'string') {
    return {
      tokens: tokenize(containerOrHTML),
      html: containerOrHTML
    };
  } else {
    return {
      tokens: tokenize(containerOrHTML.innerHTML),
      html: containerOrHTML.innerHTML
    };
  }
}