plain_text_conversion_stream.js 705 B

1234567891011121314151617181920
  1. 'use strict';
  2. var ParserStream = require('./parser_stream'),
  3. inherits = require('util').inherits,
  4. $ = require('../common/html').TAG_NAMES;
  5. var PlainTextConversionStream = module.exports = function (options) {
  6. ParserStream.call(this, options);
  7. // NOTE: see https://html.spec.whatwg.org/#read-text
  8. this.parser._insertFakeElement($.HTML);
  9. this.parser._insertFakeElement($.HEAD);
  10. this.parser.openElements.pop();
  11. this.parser._insertFakeElement($.BODY);
  12. this.parser._insertFakeElement($.PRE);
  13. this.parser.treeAdapter.insertText(this.parser.openElements.current, '\n');
  14. this.parser.switchToPlaintextParsing();
  15. };
  16. inherits(PlainTextConversionStream, ParserStream);