JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix minor bugs
authorJason Woofenden <jason@jasonwoof.com>
Thu, 24 Dec 2015 04:18:37 +0000 (23:18 -0500)
committerJason Woofenden <jason@jasonwoof.com>
Thu, 24 Dec 2015 04:18:37 +0000 (23:18 -0500)
parse-html.coffee

index 2b8fda7..0fb97b9 100644 (file)
@@ -468,7 +468,7 @@ svg_attribute_fixes = {
        diffuseconstant: 'diffuseConstant'
        edgemode: 'edgeMode'
        externalresourcesrequired: 'externalResourcesRequired'
-       filterres: 'filterRes'
+       # WTAG removes this: filterres: 'filterRes'
        filterunits: 'filterUnits'
        glyphref: 'glyphRef'
        gradienttransform: 'gradientTransform'
@@ -1676,7 +1676,7 @@ parse_html = (args) ->
                        parse_error()
                        return if template_tag_is_open()
                        root_attrs = open_els[open_els.length - 1].attrs
-                       for a of t.attrs_a
+                       for a in t.attrs_a
                                root_attrs[a[0]] = a[1] unless root_attrs[a[0]]?
                        return
 
@@ -3019,28 +3019,31 @@ parse_html = (args) ->
 
        # 8.2.4.8 http://www.w3.org/TR/html5/syntax.html#tag-open-state
        tok_state_tag_open = ->
-               switch c = txt.charAt(cur++)
-                       when '!'
-                               tok_state = tok_state_markup_declaration_open
-                       when '/'
-                               tok_state = tok_state_end_tag_open
-                       when '?'
-                               parse_error()
-                               tok_cur_tag = new_comment_token '?'
-                               tok_state = tok_state_bogus_comment
-                       else
-                               if is_lc_alpha(c)
-                                       tok_cur_tag = new_open_tag c
-                                       tok_state = tok_state_tag_name
-                               else if is_uc_alpha(c)
-                                       tok_cur_tag = new_open_tag c.toLowerCase()
-                                       tok_state = tok_state_tag_name
-                               else
-                                       parse_error()
-                                       tok_state = tok_state_data
-                                       cur -= 1 # we didn't parse/handle the char after <
-                                       return new_text_node '<'
-               return null
+               c = txt.charAt(cur++)
+               if c is '!'
+                       tok_state = tok_state_markup_declaration_open
+                       return
+               if c is '/'
+                       tok_state = tok_state_end_tag_open
+                       return
+               if is_uc_alpha(c)
+                       tok_cur_tag = new_open_tag c.toLowerCase()
+                       tok_state = tok_state_tag_name
+                       return
+               if is_lc_alpha(c)
+                       tok_cur_tag = new_open_tag c
+                       tok_state = tok_state_tag_name
+                       return
+               if c is '?'
+                       parse_error()
+                       tok_cur_tag = new_comment_token '?' # FIXME right?
+                       tok_state = tok_state_bogus_comment
+                       return
+               # Anything else
+               parse_error()
+               tok_state = tok_state_data
+               cur -= 1 # we didn't parse/handle the char after <
+               return new_text_node '<'
 
        # 8.2.4.9 http://www.w3.org/TR/html5/syntax.html#end-tag-open-state
        tok_state_end_tag_open = ->
@@ -3392,7 +3395,7 @@ parse_html = (args) ->
                # Anything else
                tok_state = tok_state_script_data_escaped
                cur -= 1 # Reconsume
-               return new_character_token c
+               return new_character_token '<'
 
        # 8.2.4.26 http://www.w3.org/TR/html5/syntax.html#script-data-escaped-end-tag-open-state
        tok_state_script_data_escaped_end_tag_open = ->
@@ -4511,7 +4514,7 @@ parse_html = (args) ->
        txt = txt.replace(new RegExp("\r\n", 'g'), "\n") # fixfull spec doesn't say this
        txt = txt.replace(new RegExp("\r", 'g'), "\n") # fixfull spec doesn't say this
 
-       if args.name is "plain-text-unsafe.dat #4"
+       if args.name is "tests16.dat #25"
                console.log "hi"
        # proccess input
        # http://www.w3.org/TR/html5/syntax.html#tree-construction