Formerly lerzegov/elm-markup. Search finds this package by either name.
This module allows you to make edits to Parsed, that intermediate data structure we talked about in Mark.
This means you can build an editor for your document.
In order to make edits to your document you need an Id and an Edit.
Once you have those you can update your document, which can succeed or fail depending on if the edit was valid.
ParsedEvery block has an Id. You can retrieve the Id for a block using Mark.withId
Here are edits you can make against Mark.text and Mark.textWith blocks.
Note These edits don't apply to Mark.string. If you want to modify a Mark.string, use Mark.Edit.replace.
The index of the rendered String. Let's say you have this string in your markup source.
Here is *my string*.When you're rendering this, it's broken into three segments.
Here ismy string (which is bold).The Offset is character position where those three strings are considered as one big one.
Here are some lookups:
0 -> H8 -> m17 -> .We're not counting control characters from our markup source.
This will work on both styled text and string datatypes.
Remove all styling on the text selection and replace with the given styling.
Add the given styles if they are not present in the text selection.
Note: Other styling is unaffected.
Remove the given styles if they are present in the text selection.
Note: Other styling is unaffected.
Put the current text selection within an annotation with some attributes.
Here's an example that would turn the selection into a link.
Mark.Edit.annotate id
start
end
"link"
[ ( "url", Mark.New.string "https://guide.elm-lang.org/" ) ]Note existing annotations within the selection are removed.
Same as annotate, but creates a verbatim instead.
Note existing annotations within the selection are removed.
The Block mentioned here is actually a Mark.New.Block. Use Mark.New to create the new block you'd like.
Delete blocks.
This may fail if the block cannot be deleted(such as a field in a record).
Insert a block at an index within a Mark.manyOf.
Insert a block at the first position.
The id needed here is of the parent.