Formerly lerzegov/elm-markup. Search finds this package by either name.
Create a new Mrk.Block that can be added to your document using Mrk.Edit.replace or Mrk.Edit.insertAt.
Let's say we are capturing a basic diagram in our document and we want to dynamically insert a circle.
We can make a new circle by writing the following function
import Mrk.New as New
type alias Circle =
{ x : Int
, y : Int
, label : String
}
circle : Circle -> Mrk.New.Block
circle details =
New.record "Circle"
[ ( "label", New.string details.label )
, ( "x", New.int details.x )
, ( "y", New.int details.y )
]And then insert our newly made circle using Mrk.Edit.insertAt.
Note: The document will only accept edits which are valid.
Here's an example of creating some text.
newText =
New.text
[ Mrk.unstyled "Look at my "
, Mrk.bold "cool"
, Mrk.unstyled " new text!"
]New.annotation
{ name = "link"
, text =
[ New.unstyled "my link to the elm website!" ]
, fields =
[ ( "url", Mrk.string "https://elm-lang.com" ) ]
}