How to use the simple-html-tokenizer.EventedTokenizer function in simple-html-tokenizer

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 / evented-tokenizer-tests.ts View on Github external
function tokenize(input: string) {
  var tokenizer = new EventedTokenizer(
    delegate,
    new EntityParser(HTML5NamedCharRefs)
  );

  tokenizer.tokenize(input);
}
github glimmerjs / glimmer-vm / packages / glimmer-syntax / lib / parser.ts View on Github external
export function Parser(source, options) {
  this.options = options || {};
  this.elementStack = [];
  this.tokenizer = new EventedTokenizer(this, entityParser);

  this.currentNode = null;
  this.currentAttribute = null;

  if (typeof source === 'string') {
    this.source = source.split(/(?:\r\n?|\n)/g);
  }
}
github glimmerjs / glimmer-vm / packages / @glimmer / syntax / lib / parser.ts View on Github external
combined = plugin.transform(combined);
    }
  }

  return combined;
}

const entityParser = new EntityParser(namedCharRefs);

export class Parser {
  private elementStack = [];
  private options: Object;
  private source: string[];
  public currentAttribute = null;
  public currentNode = null;
  public tokenizer = new EventedTokenizer(this, entityParser);

  constructor(source, options: Object = {}) {
    this.options = options;

    if (typeof source === 'string') {
      this.source = source.split(/(?:\r\n?|\n)/g);
    }
  }

  acceptNode(node): Object {
    return this[node.type](node);
  }

  currentElement(): Object {
    return this.elementStack[this.elementStack.length - 1];
  }
github glimmerjs / glimmer-vm / packages / @glimmer / syntax / lib / hbs / parse / html.ts View on Github external
function isAttrValue(node: hbs.Statement | null): node is hbs.AttrValue {
  if (node === null) return true;

  switch (node.type) {
    case 'TextNode':
    case 'MustacheStatement':
    case 'MustacheContent':
    case 'ConcatStatement':
      return true;
    default:
      return false;
  }
}

export class HtmlParser implements TokenizerDelegate {
  readonly tokenizer = new EventedTokenizer(this, entityParser);

  constructor(private source: string, private parser: HandlebarsParser) {}

  seek(from: number) {
    (this.tokenizer as any).index = from;
    (this.tokenizer as any).input = this.source.slice(0, from);
  }

  get pos() {
    return (this.tokenizer as any).index;
  }

  reset(): void {
    return;
  }