From b4c4074e49348fa101526604d002c776f65a3c87 Mon Sep 17 00:00:00 2001 From: jultty Date: Sat, 24 Feb 2024 15:22:51 -0300 Subject: [PATCH] Add Lua filter for title string --- posts/filters/title.lua | 15 +++++++++++++++ posts/gen.ml | 8 ++++---- posts/html/scripts-em-ocaml.md.html | 6 ++---- posts/{ => markdown}/scripts-em-ocaml.md | 4 +--- 4 files changed, 22 insertions(+), 11 deletions(-) create mode 100755 posts/filters/title.lua rename posts/{ => markdown}/scripts-em-ocaml.md (98%) diff --git a/posts/filters/title.lua b/posts/filters/title.lua new file mode 100755 index 0000000..cc1e735 --- /dev/null +++ b/posts/filters/title.lua @@ -0,0 +1,15 @@ +-- source: https://stackoverflow.com/a/76048743 + +local title + +function Header(e) + if title then return end + title = pandoc.utils.stringify(e) .. " • jutty.dev" +end + +function Meta(e) + if not e.pagetitle then + e.pagetitle = title + return e + end +end diff --git a/posts/gen.ml b/posts/gen.ml index be6dae3..79fc618 100755 --- a/posts/gen.ml +++ b/posts/gen.ml @@ -1,14 +1,14 @@ #!/usr/bin/env utop -let args css = "--css " ^ css ^ " -s --to html5 --highlight-style zenburn " +let args = "--css ../../assets/style.css -s --to html5 " ^ + "--highlight-style zenburn " ^ "--lua-filter filters/title.lua " let vert md = begin Sys.command ( - "pandoc " ^ args "../../assets/style.css" ^ md ^ " -o html/" ^ md ^ ".html " + "pandoc " ^ args ^ " markdown/" ^ md ^ " -o html/" ^ md ^ ".html " ) end ;; -let contents = Sys.readdir "." +let contents = Sys.readdir "./markdown/" |> Array.to_list - |> List.filter (fun e -> e <> "gen.ml" && e <> "html") |> List.map vert diff --git a/posts/html/scripts-em-ocaml.md.html b/posts/html/scripts-em-ocaml.md.html index 0813b9f..b72d4fe 100644 --- a/posts/html/scripts-em-ocaml.md.html +++ b/posts/html/scripts-em-ocaml.md.html @@ -4,7 +4,7 @@ - Scripts em OCaml + Scripts em OCaml • jutty.dev