FuncyDown is a very simple library to create Markdown files written in F#. The readme you are currently reading is generated with FuncyDown.
These examples show how to use FuncyDown in your application to create a Markdown file.
You can easily add headers of different size to your Markdown document.
open FuncyDown.Element
open FuncyDown.Document
emptyDocument
|> addH1 "Header size 1"
|> addH2 "Header size 2"
|> addH3 "Header size 3"
|> addH4 "Header size 4"
|> addH5 "Header size 5"
|> addH6 "Header size 6"
|> addHeader H3 "Header of specific size (example 3)"
There are several option to work with text.
emptyDocument
|> addParagraph "Text to put into an paragraph."
|> addEmphasis "Text to emphasize (italic)."
|> addStrongEmphasis "Text to strongly emphasize (bold)"
|> addStrikeThrough "Text to strike through."
Adding a table is also very easy.
let headers = ["Header 1"; "Header 2"; "Header 3"]
let rows =
[
["Content"; "Content"; "Content"]
["Content"; "Content"; "Content"]
["Content"; "Content"; "Content"]
]
emptyDocument
|> addTable headers rows
You can create ordered and unordered list with sub-items.
let items =
[
{Text = "Level 0 item."; Intend = 0}
{Text = "Level 1 item."; Intend = 1}
{Text = "Level 2 item."; Intend = 2}
{Text = "Level 0 item."; Intend = 0}
]
emptyDocument
|> addUnorderedList items
|> addOrderedList items
You can add a link to an internal or external reference and to images which will be displayed in the Markdown document.
emptyDocument
|> addLink {Text = "Some link text"; Target = "https://.../index.html"; Title = Some("Optional title")}
|> addImage {AltText = "Some link text"; Target = "https://.../image.png"; Title = Some("Optional title")}
To add code, you have two option. Either as in-line code or as a code block.
emptyDocument
|> addInlineCode {Code = "Inline code"; Language = None}
|> addBlockCode {Code = "Inline code"; Language = Some("fsharp")}
Sometimes it's useful to have a block quote to highlight some text or quote a source.
emptyDocument
|> addBlockQuote "Text to quote."
To add a simple horizontal rule use the code below.
emptyDocument
|> addHorizontalRule
As an alternative to the pipe operator, the toDoc
function can be used to construct a Markdown document.
let document = Document.toDoc [
addH1 "FuncyDown is fancy!"
addParagraph "Lemonade was a popular drink, and it still is!"
]
The render function writes directly to a Markdown string.
let markdown = Document.render [
addH1 "FuncyDown is fancy!"
addParagraph "Lemonade was a popular drink, and it still is!"
]
To save the generated Markdown document on disk or use it otherwise, you can export the document to a formatted Markdown string.
...
markdownDocument |> asString