update extensions

This commit is contained in:
2024-05-14 00:11:21 +02:00
parent c024532262
commit aa4af0c42a
6 changed files with 116 additions and 9 deletions

View File

@@ -15,3 +15,7 @@ contributes:
pdf:
include-in-header:
- "resources/tex/juliainc.tex"
typst:
include-in-header:
- "resources/typst/juliainc.typ"

View File

@@ -118,6 +118,55 @@ local function LaTeXconverter(fg, bg, bold, light, italic, underline, inverse)
return starttag, endtag
end
local function Typstconverter(fg, bg, bold, light, italic, underline, inverse)
local starttag = "raw(\""
local endtag = "\")"
if inverse then
fg, bg = bg, fg
end
if underline then
starttag = "show: c => underline(c);" .. starttag
end
if type(bg) == "number" then
starttag = "show: c => invertbox(" .. ANSI_COLORS[bg+1] .. ",c);" .. starttag
elseif type(bg) == "table" then
starttag = string.format("show: c => invertbox(rgb(%d,%d,%d),c);", bg[1], bg[2], bg[3]) .. starttag
elseif inverse then
starttag = "show: c => invertbox(ansi-default-inverse-bg ,c);" .. starttag
end
if type(fg) == "number" then
starttag = "set text(fill:" .. ANSI_COLORS[fg+1] ..");" .. starttag
elseif type(fg) == "table" then
starttag = string.format("set text(fill:rgb(%d,%d,%d));", fg[1], fg[2], fg[3]) .. starttag
elseif inverse then
starttag = "set text(fill: ansi-default-inverse-fg);" .. starttag
end
if italic then
starttag = "set text(style:\"italic\");" .. starttag
end
if bold then
starttag = "set text(weight:\"bold\");" .. starttag
end
if light then
starttag = "set text(weight:\"light\");" .. starttag
end
return "#{" .. starttag, endtag.."}"
end
local function HTMLconverter(fg, bg, bold, light, italic, underline, inverse)
if not (fg or bg or bold or light or italic or underline or inverse) then
return "",""
@@ -184,6 +233,9 @@ local function codeBlockTrans(e)
elseif quarto.doc.isFormat('html') then
converter = HTMLconverter
fmt = 'html'
elseif quarto.doc.isFormat('typst') then
converter = Typstconverter
fmt = 'typst'
else
return
end
@@ -316,6 +368,10 @@ local function codeBlockTrans(e)
if fmt == 'latex' then
return pandoc.RawBlock(fmt, [[\begin{]]..texenv.."}\n"..out.."\n"..[[\end{]].. texenv .. "}")
end
if fmt == 'typst' then
return pandoc.RawBlock(fmt, "#"..texenv.."[\n"..out.."\n]")
end
end

View File

@@ -0,0 +1,31 @@
#show raw: set text(font: "JuliaMono")
// define cell layout
#let OutputCell = block.with(width:100%, inset: 5pt)
#let AnsiOutputCell = block.with(width: 100%, inset: 5pt)
#let StderrOutputCell = block.with(width: 100%, stroke: 1pt + red, inset: 5pt)
//#set highlight(top-edge: "ascender", bottom-edge: "descender")
#let invertbox(color, c) = box(outset: (x: 0.05em, y: 0.25em), fill: color, c)
//https://github.com/typst/typst/discussions/3057q
#let ansi-black = rgb("#3E424D")
#let ansi-black-intense = rgb("#282C36")
#let ansi-red = rgb("#E75C58")
#let ansi-red-intense = rgb("#B22B31")
#let ansi-green = rgb("#00A250")
#let ansi-green-intense = rgb("#007427")
#let ansi-yellow = rgb("#DDB62B")
#let ansi-yellow-intense = rgb("#B27D12")
#let ansi-blue = rgb("#208FFB")
#let ansi-blue-intense = rgb("#0065CA")
#let ansi-magenta = rgb("#D160C4")
#let ansi-magenta-intense = rgb("#A03196")
#let ansi-cyan = rgb("#60C6C8")
#let ansi-cyan-intense = rgb("#258F8F")
#let ansi-white = rgb("#C5C1B4")
#let ansi-white-intense = rgb("#A1A6B2")
#let ansi-default-inverse-fg = rgb("#FFFFFF")
#let ansi-default-inverse-bg = rgb("#000000")