erste schritte

This commit is contained in:
Meik Hellmund 2022-09-21 17:06:53 +02:00
parent 6088fe9a22
commit 168467ba76
2 changed files with 80 additions and 4 deletions

View File

@ -2,11 +2,13 @@ pandoc -t native --ipynb-output=best 2_NumTypes.ipynb |jq
quarto commit:
https://github.com/quarto-dev/quarto-cli/commit/2bd7b8719ecf8916f5754c0f3ac63ba5d7597c31
https://github.com/quarto-dev/quarto-cli/issues/929
quarto discussion:
my quarto discussion:
https://github.com/quarto-dev/quarto-cli/discussions/2488
pandoc discussion:
my pandoc discussion:
https://groups.google.com/g/pandoc-discuss/c/kFqvcZ1M8dw
nbconvert filter:
@ -31,3 +33,7 @@ https://github.com/jgm/pandoc/issues/6643
pandoc -t native --ipynb-output=all --lua-filter=ansi2html.lua 2_NumTypes.ipynb -o kkk
http://lua-users.org/wiki/AnsiTerminalColors
ANSI codes
https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797

View File

@ -1,3 +1,31 @@
-- this is essentially
-- https://github.com/jupyter/nbconvert/blob/main/nbconvert/filters/ansi.py
-- converted to lua
local ANSI_COLORS = {
"ansi-black",
"ansi-red",
"ansi-green",
"ansi-yellow",
"ansi-blue",
"ansi-magenta",
"ansi-cyan",
"ansi-white",
"ansi-black-intense",
"ansi-red-intense",
"ansi-green-intense",
"ansi-yellow-intense",
"ansi-blue-intense",
"ansi-magenta-intense",
"ansi-cyan-intense",
"ansi-white-intense"
}
local re = require "re"
local codes = {
-- attributes
reset = 0,
@ -29,10 +57,52 @@ local codes = {
onwhite = 47,
}
local ANSI = re.compile [[
'\x1b%[' {.*?} {[@-~]}
]]
function CodeBlock(e)
if string.find(e.text, "\u{001b}\u{005b}", 1, true) then
local s1, e1, c1, d1 = string.find(e.text, "\x1b%[(.-)([@-~])")
if s1 then
print(e.text)
print(s1, e1, c1, d1)
local text = e.text
local out = ""
while text do
s1, e1, c1, d1 = string.find(text, "\x1b%[(.-)([@-~])")
if s1 then
if d1=="m" then
local numbers={}
for i in string.gmatch(c1, "[^;]") do
table.insert(numbers, tonumber(i))
end
end
end
end
end
end
function CodeBlockx(e)
if FORMAT:match 'latex' or FORMAT:match 'latex' or FORMAT:match 'native' then
local s1, e1 = string.find(e.text, "\u{001b}\u{005b}", 1, true)
if s1 then
local i = 1
local res = ""
--while i <= #e.text do
--end
-- res = ""
-- for i=1, #e.text) do
-- end
--s1,e1 = string.find(e.text, "\x1b%[") -- "\x1b\\[(.*?)([@-~])"
-- if s1 then
print(#e.text)
print(s1,e1)
end
end
end