Skip to content

Commit

Permalink
ok fixed, updated diagram.lua too
Browse files Browse the repository at this point in the history
  • Loading branch information
fradav committed May 14, 2024
1 parent 1ca3a21 commit 22352ff
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
mkdir -p ~/.local/bin
~/.TinyTeX/bin/x86_64-linux/tlmgr option sys_bin ~/.local/bin
~/.TinyTeX/bin/x86_64-linux/tlmgr path add
~/.TinyTeX/bin/x86_64-linux/tlmgr install libertinus-otf
~/.TinyTeX/bin/x86_64-linux/tlmgr install libertinus-fonts
- name: install dependencies for diagram.lua and webshot2
run: sudo apt update && sudo apt install -y inkscape libcurl4-openssl-dev
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
/.luarc.json
/.quarto/
/*_files
/*_cache
/_freeze
.Rprofile
computo-quarto-extension.html
computo-quarto-extension.pdf
_environment
/.micromamba/

21 changes: 13 additions & 8 deletions _extensions/computo/_extensions/pandoc-ext/diagram/diagram.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PANDOC_VERSION:must_be_at_least '3.0'
if warn then
warn '@on'
else
warn = function (...) io.stderr:write(...) end
warn = function(...) io.stderr:write(table.concat({ ... })) end
end

local system = require 'pandoc.system'
Expand Down Expand Up @@ -148,8 +148,7 @@ local mermaid = {
--- packages as the first, and the actual TikZ code as the second
--- argument.
local tikz_template = pandoc.template.compile [[
\documentclass{standalone}
\usepackage{tikz}
\documentclass[tikz]{standalone}
$for(header-includes)$
$it$
$endfor$
Expand Down Expand Up @@ -192,21 +191,27 @@ local tikz = {
write_file(tikz_file, tex_code)

-- Execute the LaTeX compiler:
pandoc.pipe(
local output, status, signal = pandoc.pipe(
self.execpath or 'pdflatex',
{'-output-directory', tmpdir, tikz_file},
{ '-interaction=nonstopmode', '-output-directory', tmpdir, tikz_file },
''
)

return read_file(pdf_file), 'application/pdf'
pdf_content = read_file(pdf_file)
if status ~= 0 or signal ~= 0 or pdf_content == nil then
warn(string.format(
"pdflatex failed with status %s and signal %s. Output:\n%s",
tostring(status), tostring(signal), tostring(output)))
end

return pdf_content, 'application/pdf'
end)
end)
end
}

--- Asymptote diagram engine
local asymptote = {
line_comment_start = '//',
line_comment_start = '%%',
mime_types = {
['application/pdf'] = true,
},
Expand Down
14 changes: 14 additions & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
project:
title: "computo-quarto-extension"
render:
- computo-quarto-extension.qmd
resources:
- environment.yml
- .nojekyll

execute:
cache: true
freeze: auto

format:
computo-html:
output-file: index.html
computo-pdf: default

0 comments on commit 22352ff

Please sign in to comment.