diff --git a/lib/Render/Head.rakumod b/lib/Render/Head.rakumod index c93c3ff..22fa4ee 100644 --- a/lib/Render/Head.rakumod +++ b/lib/Render/Head.rakumod @@ -47,7 +47,6 @@ sub site-header(BlogMeta:D $meta) is export { sub header-link($name, $path, $icon) { a :href("$path"), [ icon $icon; - ' '; span $name; ] } diff --git a/lib/Render/Util.rakumod b/lib/Render/Util.rakumod index 79ece58..0d7adcb 100644 --- a/lib/Render/Util.rakumod +++ b/lib/Render/Util.rakumod @@ -10,7 +10,8 @@ sub show-html($html) is export { # Work around HTML::Functional automatically putting newlines between tags $out ~~ s:g/'' \v+ ''/<\/i>/; $out ~~ s:g/\v+ ''/<\/a>/; - $out ~~ s:g/',' \v+ ' [!NOTE] > As this is a literate Idris document, and we haven't defined our `printf` @@ -33,13 +34,32 @@ Our goal is to provide a printf function that can be called, much like it's C eq ```idris failing example_usage : String - example_usage = printf "%s %d %02d" "hello" 1 2 + example_usage = printf "%s %d %2d" "hello" 1 2 ``` - - ## Parsing a Format String +First, we need a data structure to describe our format string. We define the +`Format` data type, with constructors for each of the format specifiers we will +be supporting, as well as a constructor to hold literal components. + +```idris +data Format : Type where + ||| A slot that should be filled in with a number + Number : (next : Format) -> Format + ||| A slot that should be filled in with a number, padded to a certian number + ||| of digits + PaddedNumber : (digits : Nat) -> Format + ||| A slot that should be filled in with a string + Str : (next : Format) -> Format + ||| A literal component of the format string that should not be interpolated + Literal : (literal : String) -> (next : Format) -> Format + ||| The end of the format string + End : Format +``` + ## Calculating a Type From a Format String ## printf + +## Working with run-time format strings