WIP: Syntax highlight colors
This commit is contained in:
parent
6bd8898125
commit
46aa6c829f
@ -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/
|
||||
|
||||
|
1
html/.gitignore
vendored
1
html/.gitignore
vendored
@ -13,3 +13,4 @@ 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
|
||||
pygments.css
|
@ -1,4 +1,6 @@
|
||||
<article>
|
||||
$render{"test"}
|
||||
</article>
|
||||
|
||||
$render{"templates/wares"}
|
||||
|
||||
|
@ -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('<div class="highlight"><pre>(.-)\n?</pre></div>')
|
||||
rep = '<div class="sourceCode"><pre class="sourceCode ' .. 'moonscript"><code class="sourceCode ' .. 'moonscript">' .. mat .. '</code></pre></div>'
|
||||
out = out\gsub('<div class="highlight"><pre>(.-)\n?</pre></div>', rep)
|
||||
|
||||
out
|
||||
|
||||
-- get rid of the div and pre inserted by pygments
|
||||
-- assert out\match('^<div class="highlight"><pre>(.-)\n?</pre></div>'),
|
||||
-- "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
|
||||
|
@ -129,3 +129,4 @@ sitegen.create =>
|
||||
|
||||
copy "app.css"
|
||||
copy "moonscript.css"
|
||||
copy "pygments.css"
|
||||
|
@ -12,6 +12,7 @@
|
||||
media="screen"
|
||||
/>
|
||||
<link rel="stylesheet" href="$root/app.css?$generate_date" />
|
||||
<link rel="stylesheet" href="$root/pygments.css?$generate_date" />
|
||||
<link rel="stylesheet" href="$root/moonscript.css?$generate_date" />
|
||||
</head>
|
||||
<body class="bg-white">
|
||||
|
18
test.md
18
test.md
@ -1,3 +1,18 @@
|
||||
```heex
|
||||
<.header>
|
||||
Listing Posts
|
||||
</.header>
|
||||
|
||||
<.table id="posts" rows={@posts} row_click={&JS.navigate(~p"/posts/#{&1}")}>
|
||||
<:col :let={post} label="id"><%= post.id %></:col>
|
||||
<:action :let={post}>
|
||||
<div class="sr-only">
|
||||
<.link navigate={~p"/posts/#{post}"}>Show</.link>
|
||||
</div>
|
||||
</:action>
|
||||
</.table>
|
||||
```
|
||||
|
||||
```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!
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user