Commits: 2

Merge branch 'content' into tree-example

Fix the tree example markup

With a workaround for parser breaking on startWith + manyOf.

index 9ef5249..6110a50 100644
--- a/content/day-4.txt
+++ b/content/day-4.txt
@@ -18,62 +18,44 @@
=| Header
=    The Problem
=
-| Note
-    FIXME: The tree example is broken.
+We want to have a tree that looks like this:
=
=| Window
=    | Tree
=        | Axiom
=            color = green
-            rotation = 0
-            age = 9
-
-        | Rule
-            | Parent
-                purple
-
-            | Child
-                color = green
-                rotation = 0.0
-
-            | Child
-                color = green
-                rotation = 30
+            rotation = -90
+            age = 8
=
-            | Child
-                color = green
-                rotation = -30
=
=        | Rule
-            | Parent
-                green
+            parent = green
=
-            | Child
-                color = brown
-                rotation = 0.0
+            children =
+                | Child
+                    color = brown
+                    rotation = 0.0
=
-            | Child
-                color = brown
-                rotation = 30
+                | Child
+                    color = brown
+                    rotation = 30
=
-            | Child
-                color = brown
-                rotation = -30
+                | Child
+                    color = brown
+                    rotation = -30
=
=        | Rule
-
-            | Parent
-                brown
-
-            | Child
-                color = green
-                rotation = 0.0
-            | Child
-                color = green
-                rotation = 30
-            | Child
-                color = green
-                rotation = -30
+            parent = brown
+            children =
+                | Child
+                    color = green
+                    rotation = 0.0
+                | Child
+                    color = green
+                    rotation = 30
+                | Child
+                    color = green
+                    rotation = -30
=
=
=The tree is built from segments: a line and a dot. In this respect it is similar to the connected dots we created yesterday. If we group the dot and a line, we will have the building block for our tree. We can do it with {Code|Svg.g} function ({Code|g} is an abbreviation of "group"). Just like {Code|Svg.svg}, it takes list of attributes and list of children. We can use it like that:
index d73c74e..bf183c7 100644
--- a/src/Main.elm
+++ b/src/Main.elm
@@ -915,14 +915,11 @@ document =
=                    Mark.manyOf [ rule ]
=
=                rule =
-                    Mark.startWith Tuple.pair
-                        parent
-                        (Mark.manyOf [ child ])
-
-                -- FIXME: Parser breaks with empty list of dead ends
-                -- Mark.stub "Rule" ( "green", [ Examples.Tree.Segment "green" 30 ] )
-                -- Mark.manyOf [ child ]
-                --     |> Mark.map (Tuple.pair "green")
+                    Mark.record2 "Rule"
+                        Tuple.pair
+                        (Mark.field "parent" Mark.string)
+                        (Mark.field "children" (Mark.manyOf [ child ]))
+
=                parent =
=                    Mark.block "Parent" identity Mark.string
=