Create a new Mark.Block
that can be added to your document using Mark.Edit.replace
or Mark.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 Mark.New as New
type alias Circle =
{ x : Int
, y : Int
, label : String
}
circle : Circle -> Mark.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 Mark.Edit.insertAt
.
Note: The document will only accept edits which are valid.
Mark.Internal.Description.Expectation
string : String -> Block
int : Basics.Int -> Block
float : Basics.Float -> Block
bool : Basics.Bool -> Block
block : String -> Block -> Block
record : String -> List ( String, Block ) -> Block
many : List Block -> Block
tree : List Tree -> Block
Here's an example of creating some text.
newText =
New.text
[ Mark.unstyled "Look at my "
, Mark.bold "cool"
, Mark.unstyled " new text!"
]
Mark.Internal.Description.InlineExpectation
text : List Text -> Block
unstyled : String -> Text
bold : String -> Text
italics : String -> Text
strike : String -> Text
{ bold : Basics.Bool
, italic : Basics.Bool
, strike : Basics.Bool
}
styled : Styles -> String -> Text
annotation : { name : String, text : List ( Styles, String ), fields : List ( String, Block ) } -> Text
New.annotation
{ name = "link"
, text =
[ New.unstyled "my link to the elm website!" ]
, fields =
[ ( "url", Mark.string "https://elm-lang.com" ) ]
}
verbatim : { name : String, text : String, fields : List ( String, Block ) } -> Text