mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(image): added math rendering for typst. Closes #1260
This commit is contained in:
parent
10387af009
commit
e2258236a2
6 changed files with 49 additions and 2 deletions
|
@ -18,11 +18,21 @@ M.transforms = {
|
|||
local line = vim.api.nvim_buf_get_lines(ctx.buf, row, row + 1, false)[1]
|
||||
img.src = line:sub(col + 1)
|
||||
end,
|
||||
typst = function(img, ctx)
|
||||
if not img.content then
|
||||
return
|
||||
end
|
||||
local fg = Snacks.util.color("SnacksImageMath") or "#000000"
|
||||
img.content = ([[
|
||||
#set page(width: auto, height: auto, margin: (x: 2pt, y: 2pt))
|
||||
#set text(size: 12pt, fill: rgb("%s"))
|
||||
%s]]):format(fg, img.content)
|
||||
end,
|
||||
latex = function(img, ctx)
|
||||
if not img.content then
|
||||
return
|
||||
end
|
||||
local fg = Snacks.util.color({ "@markup.math.latex", "Special", "Normal" }) or "#000000"
|
||||
local fg = Snacks.util.color("SnacksImageMath") or "#000000"
|
||||
img.ext = "math.tex"
|
||||
local content = vim.trim(img.content or "")
|
||||
content = content:gsub("^%$+`?", ""):gsub("`?%$+$", "")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue