mdgriffith / elm-markup

Elm-friendly markup

Home Page:https://package.elm-lang.org/packages/mdgriffith/elm-markup/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple `onError` case appears to not work

dillonkearns opened this issue · comments

Hey Matt!

I'm loving the new version, thanks for all the work on this.

I have tried Mark.onError in a few different cases and haven't seen it work. In each case, I get a Document mismatch error:

Image 2019-07-25 at 9 23 26 AM

Steps to reproduce

Apply this diff in the examples folder and run the app with

cd examples/blog && elm-live src/Main.elm --open
diff --git a/examples/blog/articles/Ipsum.emu b/examples/blog/articles/Ipsum.emu
index f9bf692..747b1d5 100644
--- a/examples/blog/articles/Ipsum.emu
+++ b/examples/blog/articles/Ipsum.emu
@@ -4,6 +4,8 @@
     description =
         How I learned to use elm-markup.
 
+|> Simple
+    Hello!
 
 `Lorem Ipsum is simply`{drop} --- dummy text of the printing and [typesetting industry]{link| url = http://mechanical-elephant.com }. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
 
diff --git a/examples/blog/src/Main.elm b/examples/blog/src/Main.elm
index 9ba8be5..e86fbed 100644
--- a/examples/blog/src/Main.elm
+++ b/examples/blog/src/Main.elm
@@ -144,6 +144,7 @@ document =
                 , image
                 , list
                 , code
+                , simple
                 , Mark.map (Html.p []) text
                 ]
         }
@@ -235,6 +236,23 @@ header =
         text
 
 
+simple =
+    Mark.block "Simple"
+        (\string ->
+            Html.text string
+        )
+        (Mark.string
+            |> Mark.verify
+                (\string ->
+                    Err
+                        { title = "Forced error"
+                        , message = [ "This is just a test." ]
+                        }
+                )
+            |> Mark.onError "I found an error!"
+        )
+
+
 image =
     Mark.record "Image"
         (\src description ->

I think Mark.onError would be a really cool feature for some of the static site generation I'm working on! Let me know if there's anything I can do to help.