diff --git a/lib/Config.rakumod b/lib/Config.rakumod index 73c4831..7418ec9 100644 --- a/lib/Config.rakumod +++ b/lib/Config.rakumod @@ -5,13 +5,17 @@ use DB::BlogMeta; unit class Config; + method generate-post(Str:D $title, Str:D $content, BlogMeta:D $meta) { - my $head = - head [ + my $head = head [ meta :charset; meta :name, :content; title "{$meta.title} — $title"; # TODO: Add style sheets + # Use Iosevka Alie as the monospace font + link :rel, + :href; + style %?RESOURCES.slurp; # TODO: Add description # TODO: Add header links ]; diff --git a/lib/DB/IdrisPost.rakumod b/lib/DB/IdrisPost.rakumod index 1c0bfbc..27a44a2 100644 --- a/lib/DB/IdrisPost.rakumod +++ b/lib/DB/IdrisPost.rakumod @@ -60,11 +60,24 @@ sub pack(*@args) { # Run a katla command, erroring on failure, returning the standard out, and # mangling the output accordingly sub katla(*@args --> Str:D) { + # Run the requested katla command my $katla = run 'katla', @args, :out, :err; my $katla-out = $katla.out.slurp: :close; my $katla-err = $katla.err.slurp: :close; die "Katla exited with {$katla.exitcode}\nout: $katla-out\nerr: $katla-err" unless $katla; - # TODO modify output + # Modify the output to use our styling instead of katla's + # Remove the style block and line breaks + $katla-out ~~ s:g/''//; + $katla-out ~~ s:g/'
'//; + # Use
 blocks for the code and inject our own class for idris code
+    $katla-out ~~ s:g/'' \s*/
/;
+    $katla-out ~~ s:g/\s* ''/<\/code><\/pre>/;
+    # Replace the highlighting classes with our own
+    $katla-out ~~ s:g/'class="Idris' (\w+) '"'/class="hl-{$/[0].lc}"/;
+    # Clean up inappropiate escaping of some characters
+    $katla-out ~~ s:g/'\\*'/*/;
+    $katla-out ~~ s:g/'\\_'/_/;
+    $katla-out ~~ s:g/'\\\\'/\\/;
     $katla-out
 }
diff --git a/projects/Idris/src/Posts/HelloWorld.md b/projects/Idris/src/Posts/HelloWorld.md
index 026080b..8e4f3f8 100644
--- a/projects/Idris/src/Posts/HelloWorld.md
+++ b/projects/Idris/src/Posts/HelloWorld.md
@@ -5,3 +5,27 @@ module Posts.HelloWorld
 
 %default total
 ```
+
+Here is an example function that prints to the standard out:
+
+```idris
+main : IO ()
+main = do
+  putStrLn "Hello World"
+  putStrLn "Hello \n with new lines \n world"
+  putStrLn "And some other potential problem characters: * _"
+```
+
+And a function with some more stuff:
+
+```idris
+-- A regular comment
+
+||| A doc comment
+thingomizer : (a : String) -> IO ()
+thingomizer a = 
+  let xs = map (+ 1) [1, 2, 3, 4]
+  in do
+    putStrLn a
+    printLn xs
+```
diff --git a/resources/code.css b/resources/code.css
new file mode 100644
index 0000000..5bb4f17
--- /dev/null
+++ b/resources/code.css
@@ -0,0 +1,43 @@
+/* TODO: Move this somewhere else */
+:root {
+  color-scheme: light dark;
+}
+
+code {
+    font-family: "Iosevka Aile Web", monospace;
+    background-color: light-dark(#fbf3db, #103c48);
+    color: light-dark(#53676d, #adbcbc);
+}
+
+pre > code {
+    display: block;
+    padding: 1rem;
+}
+
+.hl-type {
+    color: light-dark(#ad8900, #dbb32d);
+}
+
+.hl-module {
+    font-style: italic;
+}
+
+.hl-function {
+    color: light-dark(#428b00, #84c747);
+}
+
+.hl-bound {
+    color: light-dark(#ca4898, #f275be);
+}
+
+.hl-keyword {
+    color: light-dark(#0072d4, #4695f7);
+}
+
+.hl-comment {
+    color: light-dark(#909995, #72898f);
+}
+
+.hl-data {
+    color: light-dark(#d2212d, #ed4a46)
+}