This library helps your library or application to generate valid markdown document programmatically.
Quit editing current child, and return to edit its parent.
Represents markdown root.
Quit modifying markdown, and compile it to the valid markdown structure.
Represents markdown section.
# Title for Root Section
Paragraph text in root section body.
Another paragraph text in root section body.
* List item in root section body
* Another list item in root section body
## Title for Child Section
Paragraph text in child section body.
```json
{
"message": "Code block in child section body."
}
```
## Title for Another Child Section
Paragraph text in another child section body.
1. Ordered list item in another child section body
1. Another ordered list item in another child section bodyStart Append Mode for editing section body.
Append new child section to the current section, and change focus to the new one.
Represents markdown list block.
Represents an item in the ListBlock.
* First `ListItem` content for this unordered `ListBlock`
Child element for the first `ListItem`.
1. This `ListItem` is in the child `ListBlock` for the First `ListItem` content.
1. This `ListItem` is also in the child `ListBlock` for the First `ListItem` content.
* Second `ListItem` content for this unordered `ListBlock`Start Push Mode for editing list item content.
Start Append Mode for editing list item children.
Represents that a is in the Append Mode, which enalbes you to append some blocks to it.
End append mode.
Append a paragraph block, and change to push mode for the paragraph.
Append an ordered list block, and change focus to it.
Append an unordered list block, and change focus to it.
Append a code block, and change focus to it.
Elm code:
appendCodeBlock
"""elm
appendCodeBlock
= Debug.todo ""
"""Generated markdown:
```elm
appendCodeBlock
= Debug.todo ""
```Represents that a is in the Push Mode, which enables you to push some inline stuffs to it.
End push mode.
Push a link.
[href](text)Push an inline code.
`inline code`Push an emphasized text.
*emphasized*Push a strongly emphasized text.
**emphasized**Push a strikethrough text.
~~strikethrough~~import MarkdownBuilder as MB
snippet : Builder Unknown ListItem -> Builder Unknown ListItem
snippet =
MB.editListItemContent
>> MB.pushText "foo "
>> MB.pushEmphasis "bar"
>> MB.endPushMode
myMarkdown : Root
myMarkdown =
root
{ title = "Markdown Builder"
}
|> editBody
|> appendOrderedList
|> appendListItem
|> applySnippet snippet
|> break
|> appendListItem
|> applySnippet snippet
|> break
|> break
|> endAppendMode
|> appendChildSection
{ title = "Builder"
}
|> editBody
|> appendUnorderedList
|> appendListItem
|> applySnippet snippet
|> run
toString myMarkdown
|> String.lines
--> [ "# Markdown Builder"
--> , ""
--> , "1. foo *bar*"
--> , "1. foo *bar*"
--> , ""
--> , "## Builder"
--> , ""
--> , "* foo *bar*"
--> ]
Markdown builder. You can build a valid markdown structure programmatically in your program: