# Converts markdown into their equivalent html pages let $markdown_files = (ls **/*.md) for $markdown in $markdown_files { let $contents = (open --raw $markdown.name) let $content_lines = ($contents | lines) let $first_line = ($content_lines | first | str trim) if $first_line == "---" { let $header = ($content_lines | skip 1 | take while {|x| ($x | str trim) != "---"} | str join "\n" | from yaml) let $post = ($content_lines | skip 1 | skip while {|x| ($x | str trim) != "---"} | skip 1) print $header let $html_post = ($post | each {|line| if ($line | str starts-with "#") { let $line = ($line | str replace "^# (.*)$" "

$1

") let $line = ($line | str replace "^## (.*)$" "

$1

") let $line = ($line | str replace "^### (.*)$" "

$1

") $line } else if $line != "" { # Otherwise, it's a paragraph # Convert images let $line = ($line | str replace --all '!\[(.+)\]\((.+)\)' '$1') let $line = ($line | str replace --all 'src="../assets' 'src="assets') # Convert links let $line = ($line | str replace --all '\[(.+?)\]\((.+?)\)' '$1') # Convert code let $line = ($line | str replace --all '`(.+?)`' '$1') $"

($line)

" } }) let $html_post = ($html_post | str join "\n") let $html_post = $" ($header.title) ($html_post) " # print $html_post let $name = ($markdown.name | path parse | update extension "html" | path join) $html_post | save --raw $name } }