From 5fc1dbe771f2cfa8323bf5e8fd7c82dfd38e8d41 Mon Sep 17 00:00:00 2001 From: Catalin Constantin Mititiuc Date: Mon, 16 Jun 2025 20:18:04 -0700 Subject: [PATCH] Refactor markdown.moon; add pandoc to Dockerfile; monkey-patch sitegen markdown renderer --- Dockerfile | 2 +- README.md | 2 -- markdown.moon | 37 ++++++++----------------------------- site.moon | 4 ++++ 4 files changed, 13 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 99959b4..9c93cd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM openresty/openresty:1.27.1.2-0-bookworm-buildpack WORKDIR /opt/app -RUN apt-get update && apt-get install -y python3-pygments +RUN apt-get update && apt-get install -y python3-pygments pandoc RUN luarocks install sitegen CMD ["sh", "-c", "openresty -p `pwd` -g 'daemon off;'"] diff --git a/README.md b/README.md index fbd62a1..27f5242 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,6 @@ ## todo -current problem: why does sitegen wrap every thing in

tags? - * treesitter highlighting for moonscript * penlight library * sitegen plugins diff --git a/markdown.moon b/markdown.moon index 975c531..531e3d5 100644 --- a/markdown.moon +++ b/markdown.moon @@ -76,39 +76,18 @@ class MarkdownRenderer extends require "sitegen.renderers.html" ext: "html" render: (page, md_source) => - discount = require "discount" - + -- discount = require "discount" md_source = page\pipe "renderer.markdown.pre_render", md_source md_source, escapes = escape_cosmo md_source - -- require("moon").p md_source - --mathjax --output=../priv/static/posts/#{output_file}.html - -- handle = io.popen "pandoc" - -- handle\write "# hello" - -- handle\flush! - -- result = handle\read("*a") - -- print result - -- handle\close! + markup_filename = os.tmpname! + input_handle = io.popen "pandoc > #{markup_filename}", "w" + input_handle\write md_source + input_handle\close! - -- require("moon").p result - - -- txt = "# hello" - -- md = "< " .. n, "w" - -- handle\write "# hello" - -- result = handle\read("*a") - -- handle\close! - - n = os.tmpname! - handle = io.popen "pandoc > " .. n, "w" - handle\write md_source - handle\close! - - f = io.open n, "r" - result = f\read("*a") - f\close! + output_handle = io.open markup_filename, "r" + result = output_handle\read "*a" + output_handle\close! html_source = assert result -- html_source = assert discount md_source diff --git a/site.moon b/site.moon index 91b9e49..9ac21a8 100644 --- a/site.moon +++ b/site.moon @@ -73,6 +73,10 @@ extract_date = (source) -> string.match path.filename(source), "%d+%-%d%d%-%d%d" format_date = (str) -> date(str)\fmt "%b %d, %Y" publish_date = (path) -> format_date extract_date path +os.execute [[ +moonc -t /usr/local/openresty/luajit/share/lua/5.1/sitegen/renderers/ markdown.moon +]] + sitegen.create => @site_title = "WebDevCat.me ยท Catalin Mititiuc" @app_name = "stasis"