diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bcb213e..89cbb25 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.gitignore b/.gitignore index 2bbefe3..f238278 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,11 @@ /.luarc.json /.quarto/ /*_files +/*_cache +/_freeze .Rprofile computo-quarto-extension.html computo-quarto-extension.pdf _environment +/.micromamba/ + diff --git a/_extensions/computo/_extensions/pandoc-ext/diagram/diagram.lua b/_extensions/computo/_extensions/pandoc-ext/diagram/diagram.lua index 3042b33..dfa27d3 100644 --- a/_extensions/computo/_extensions/pandoc-ext/diagram/diagram.lua +++ b/_extensions/computo/_extensions/pandoc-ext/diagram/diagram.lua @@ -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' @@ -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$ @@ -192,13 +191,19 @@ 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 @@ -206,7 +211,7 @@ local tikz = { --- Asymptote diagram engine local asymptote = { - line_comment_start = '//', + line_comment_start = '%%', mime_types = { ['application/pdf'] = true, }, diff --git a/_quarto.yml b/_quarto.yml index 3de3655..236f95a 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -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 \ No newline at end of file