diff --git a/Dockerfile b/Dockerfile index 5f7cdc6..c4905b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ RUN apt-get update && apt-get install -y \ wget -q -O pandoc-3.7.0.1-1-amd64.deb https://github.com/jgm/pandoc/releases/download/3.7.0.1/pandoc-3.7.0.1-1-amd64.deb && \ dpkg -i pandoc-3.7.0.1-1-amd64.deb && \ rm pandoc-3.7.0.1-1-amd64.deb + RUN luarocks install sitegen RUN luarocks install inotify INOTIFY_INCDIR=/usr/include/x86_64-linux-gnu/ diff --git a/html/.gitignore b/html/.gitignore index 5482e68..f45c541 100644 --- a/html/.gitignore +++ b/html/.gitignore @@ -12,4 +12,5 @@ posts/recursively-list-all-files-in-a-directory-with-elixir.html posts/resize-a-qemu-disk-image.html posts/set-up-a-gitweb-server.html posts/start-erlangs-dialyzer-with-gui-from-a-docker-container.html -posts/test-mix-task-file-modify.html \ No newline at end of file +posts/test-mix-task-file-modify.html +pygments.css \ No newline at end of file diff --git a/index.html b/index.html index 4a0728b..7afb924 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,6 @@ -$render{"test"} +
+ $render{"test"} +
$render{"templates/wares"} diff --git a/renderers/markdown.moon b/renderers/markdown.moon index 746c3ae..3b0230c 100644 --- a/renderers/markdown.moon +++ b/renderers/markdown.moon @@ -10,32 +10,30 @@ _prepare_command = (cmd, ...) -> args = table.concat args, " " "#{cmd} #{args}" -write_exec = (input, cmd, ...) -> - handle = io.popen _prepare_command(cmd, ...), "w" - with handle\write input - handle\close! - -convert = => - (md_source) -> - filename = os.tmpname! - write_exec md_source, @cmd, filename - Path.read_file filename - - -- fname = os.tmpname! - -- with io.open fname, "w" - -- \write md_source - -- \close! - -- - -- p = io.popen (@cmd)\format lang, fname - -- out = p\read"*a" - -- out - -- config command like this in site.moon: -- require("renderers.markdown").cmd = "pandoc --mathjax >" class PandocRenderer extends require "sitegen.renderers.markdown" unescape_cosmo = @unescape_cosmo escape_cosmo = @escape_cosmo - pandoc = convert @ + + pandoc: (md_source) => + fname = os.tmpname! + with io.popen _prepare_command(@@cmd, fname), "w" + \write md_source + \close! + + p = io.open fname + out = p\read"*a" + + if mat = out\match('
(.-)\n?
') + rep = '
' .. mat .. '
' + out = out\gsub('
(.-)\n?
', rep) + + out + + -- get rid of the div and pre inserted by pygments + -- assert out\match('^
(.-)\n?
'), + -- "Failed to parse pygmentize result, is pygments installed?" cmd: "pandoc >" @@ -43,7 +41,7 @@ class PandocRenderer extends require "sitegen.renderers.markdown" md_source = page\pipe "renderer.markdown.pre_render", md_source md_source, escapes = escape_cosmo md_source - html_source = assert pandoc md_source + html_source = assert @pandoc md_source html_source = unescape_cosmo html_source, escapes super page, html_source diff --git a/site.moon b/site.moon index 04a8cc8..4eff748 100644 --- a/site.moon +++ b/site.moon @@ -129,3 +129,4 @@ sitegen.create => copy "app.css" copy "moonscript.css" + copy "pygments.css" diff --git a/templates/root.html b/templates/root.html index c46440e..c1ac250 100644 --- a/templates/root.html +++ b/templates/root.html @@ -12,6 +12,7 @@ media="screen" /> + diff --git a/test.md b/test.md index 84f3476..79ae447 100644 --- a/test.md +++ b/test.md @@ -1,3 +1,18 @@ +```heex +<.header> + Listing Posts + + +<.table id="posts" rows={@posts} row_click={&JS.navigate(~p"/posts/#{&1}")}> + <:col :let={post} label="id"><%= post.id %> + <:action :let={post}> +
+ <.link navigate={~p"/posts/#{post}"}>Show +
+ + +``` + ```elixir if config_env() != :prod do # Configure pandoc (the version is required) @@ -13,8 +28,6 @@ if config_env() != :prod do end ``` -**this is a string!!** - ```moon class Thing name: "unknown" @@ -26,3 +39,4 @@ with Person! .name = "MoonScript" \say_name! ``` +