]
if typeof module isnt 'undefined' and module.exports?
- wheic_parser = require './parser.coffee'
+ peach_parser = require './parser.coffee'
else
- wheic_parser = window.wheic_parser
+ peach_parser = window.peach_parser
serialize_els = (els, prefix = '| ') ->
ret = ''
for el in els
switch el.type
- when wheic_parser.TYPE_TAG
+ when peach_parser.TYPE_TAG
ret += "#{prefix}<"
- if el.namespace is wheic_parser.NS_MATHML
+ if el.namespace is peach_parser.NS_MATHML
ret += "math "
- if el.namespace is wheic_parser.NS_SVG
+ if el.namespace is peach_parser.NS_SVG
ret += "svg "
ret += "#{el.name}>\n"
attr_keys = []
attr_keys.sort() # TODO this should be "lexicographically by UTF-16 code unit"
for k in attr_keys
ret += "#{prefix} #{k}=\"#{el.attrs[k]}\"\n"
- if el.name is 'template' and el.namespace is wheic_parser.NS_HTML
+ if el.name is 'template' and el.namespace is peach_parser.NS_HTML
ret += "#{prefix} content\n"
ret += serialize_els el.children, "#{prefix} "
else
ret += serialize_els el.children, "#{prefix} "
- when wheic_parser.TYPE_TEXT
+ when peach_parser.TYPE_TEXT
ret += "#{prefix}\"#{el.text}\"\n"
- when wheic_parser.TYPE_COMMENT
+ when peach_parser.TYPE_COMMENT
ret += "#{prefix}<!-- #{el.text} -->\n"
- when wheic_parser.TYPE_DOCTYPE
+ when peach_parser.TYPE_DOCTYPE
ret += "#{prefix}<!DOCTYPE #{el.name}"
if (el.public_identifier? and el.public_identifier.length > 0) or (el.system_identifier? and el.system_identifier.length > 0)
ret += " \"#{el.public_identifier ? ''}\""
test_results = passed: 0, failed: 0
test_parser = (args) ->
- wheic_parser.debug_log_reset()
+ peach_parser.debug_log_reset()
parse_errors = []
args.error_cb = (i) ->
parse_errors.push i
prev_node_id = 0 # reset counter
- parsed = wheic_parser.parse args.html, args
+ parsed = peach_parser.parse args.html, args
serialized = serialize_els parsed
if serialized isnt args.expected
test_results.failed += 1
if test_results.failed is 1
- wheic_parser.debug_log_each (str) ->
+ peach_parser.debug_log_each (str) ->
console.log str
console.log "FAILED: \"#{args.name}\""
console.log " Input: #{args.html}"