]> gitweb.factorcode.org Git - factor.git/commitdiff
modern: treat tab as whitespace and add test case.
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 3 Jun 2022 03:33:08 +0000 (22:33 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 3 Jun 2022 03:45:42 +0000 (22:45 -0500)
extra/modern/html/html-tests.factor
extra/modern/html/html.factor
extra/modern/slices/slices.factor

index b82b11d976e12035059440089def9fbaa37b6acb..5bd1cd141db798d95c0b4f4f6fa950f9e1b7fd33 100644 (file)
@@ -186,3 +186,63 @@ IN: modern.html.tests
     </html>
     ]] string>html
 ] unit-test
+
+
+! Handle tabs
+{
+V{
+    T{ open-tag
+        { open "<" }
+        { name "label" }
+        { props
+            V{
+                {
+                    "id"
+                    T{ dquote { payload "p-personal-label" } }
+                }
+                {
+                    "class"
+                    T{ dquote
+                        { payload "vector-menu-heading " }
+                    }
+                }
+            }
+        }
+        { close ">" }
+        { children
+            V{
+                T{ open-tag
+                    { open "<" }
+                    { name "span" }
+                    { props
+                        V{
+                            {
+                                "class"
+                                T{ dquote
+                                    { payload
+                                        "vector-menu-heading-label"
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    { close ">" }
+                    { children V{ "Personal tools" } }
+                    { close-tag T{ close-tag { name "span" } } }
+                }
+            }
+        }
+        { close-tag T{ close-tag { name "label" } } }
+    }
+}
+} [
+[[
+       <label
+               id="p-personal-label"
+               
+               class="vector-menu-heading "
+       >
+               <span class="vector-menu-heading-label">Personal tools</span>
+       </label>
+]] string>html
+] unit-test
index f91b7c5badb81b03675f40c8b690bbc3807d6dd5..26cdc2ca88982a6b7e1cd444710653df7d769d32 100644 (file)
@@ -89,7 +89,7 @@ C: <dquote> dquote
     } case ;
 
 : read-prop ( n string -- n' string prop/f closing/f )
-    skip-whitespace "\s\n\r\"'<=/>?" slice-til-either {
+    skip-whitespace "\s\n\r\t\"'<=/>?" slice-til-either {
         { CHAR: < [ "< error" throw ] }
         { CHAR: = [ 1 split-slice-back drop >string [ read-value ] dip swap 2array f ] }
         { CHAR: / [ ">" expect-and-span 2 split-slice-back [ >string f like ] bi@ ] }
@@ -100,6 +100,7 @@ C: <dquote> dquote
         { CHAR: \s [ >string f ] }
         { CHAR: \r [ >string f ] }
         { CHAR: \n [ >string f ] }
+        { CHAR: \t [ >string f ] }
         { f [ "efff" throw ] }
     } case ;
 
index 02a31fe492850105eb83f72acc2250554efa7be4..f52216ac0d5c9908c05f6450d8fe5be8c5bc81ac 100644 (file)
@@ -117,7 +117,7 @@ ERROR: expected-sequence-error expected actual ;
 
 :: slice-til-not-whitespace ( n string -- n' string slice/f ch/f )
     n [
-        n string [ "\s\r\n" member? not ] find-from :> ( n' ch )
+        n string [ "\s\r\n\t" member? not ] find-from :> ( n' ch )
         n' string
         n n' string ?<slice>
         ch