It’s finally come time to release v3.0 of
elm-markup! I’m very excited, this has been quite the endeavor.
I got really interested in creating a markup language for two reasons.
- Markdown doesn’t play nicely with
elm-uior interactive views written in Elm.
- I wanted to write interactive fiction for a video game I’m designing, which means intermingling styled text and structured data. …or just realizing everything should be structured/known data, but also lightweight and easy to write.
So, what is Elm Markup?
Well, I gave a talk at Oslo Elm Day which might be a good place to start (Side note, Olso Elm Day is a fantastic conference.)
But to give a brief summary:
- Elm Markup is a lightweight markup langauge where the structure is defined beforehand.
- You define your document in Elm in a similar way you’d define a JSON decoder.
- Once defined, you can parse the markup and get a rendered result, which could be
elm-uiElements, or even just a list of records. Since you define what you’re decoding to, it can be anything.
That’s the basic functionality for a markup language, but you can go further.
Because once we know the structure that the document should be, we can have nice Elm-esque errors:
Beyond this, I wanted some other capabilities I didn’t usually associate with a markup language:
- To parse your markup into an intermediate data structure called a
Mark.Parsed(basically an AST)
- Make edits to
Mark.Edit.update. (They will be checked to ensure they are valid edits)
- Render that
Parsedinto your result.
Parsedback into an elm-markup source.
This is cool because it means
elm-markup can be the “brain” of a rich text editor. Or really any sort of editor you’d like to make. Graph-based note taker? Definitely. Embed an interactive drawing program in your blogpost? Why not?
This goes back to reason
2. that I was making this, which is that many game engines benefit from having bespoke, embedded editors in the game.
And because apparently I go nuts when I do a project, I also created
- An Elm Markup CLI which will check your markup source files (*.emu) for errors using any exposing
Mark.Documents in your elm project.
- A VS Code Extension with syntax highlighting and error reporting based on the output of the CLI.
So, if your interested in getting started, checkout the examples
I’m particularly excited about the editor example, which is the beginning of a rich text editor in Elm!
Though a caveat, it needs a number of improvements which I’ve listed in the Readme. My hope is that the example shows that some of the really difficult parts about creating an editor are taken care of.
And my other hope is that all of this sparks your creativity.
Whew, this project has quite a lot of surface area, so let me know in the issues if I missed something.
Also, small apologies for the long post :). I didn’t even get into the other cool things that came along with this project like building a tolerant parser that can continue after a parsing error…maybe I should write that up too.