Formatting a calendar for markdown display

Published

May 3, 2024

Caution

Incomplete draft content.

Notes:

Collect a calendar week: the result is a Vector of LiturgicalDays.

using Lectionary
wk = calendar_week()
7-element Vector{Union{Nothing, LiturgicalDay}}:
 the fifth Sunday of Easter, April 28, 2024
 nothing
 nothing
 nothing
 nothing
 nothing
 nothing

Format a Markdown table with a column for each day:

mdlines = [
    "| Sunday | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday |",
    "| --- | --- | --- | --- | --- | --- | ---  |"
]
oneweek = []
for litday in wk
    if isnothing(litday)
        push!(oneweek," ")
    else
        push!(oneweek, string(litday))
    end
end
wkstring = "| " * join(oneweek, " | ") * " |"
push!(mdlines, wkstring)

In an environment like Pluto, VS Code, or with quarto publish, we can use the Markdown package’s parse function to create displayable output:

using Markdown
join(mdlines,"\n") * "\n" |> Markdown.parse
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
the fifth Sunday of Easter, April 28, 2024