HTMLconverter started

This commit is contained in:
Meik Hellmund 2022-09-21 21:01:18 +02:00
parent 168467ba76
commit b3aa8ca505
2 changed files with 60 additions and 33 deletions

View File

@ -37,3 +37,21 @@ http://lua-users.org/wiki/AnsiTerminalColors
ANSI codes
https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
check (esp. Latex) documenter.jl,
https://juliadocs.github.io/Documenter.jl/stable/man/syntax/#@example-block
@example blocks support colored text output by mapping ANSI escape codes to HTML.
-- nothing for latex
jupyter nbconvert,
html: prima
latex mit juliamono: sind noch undef. escapesequencen drinne
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm, colback=cellbackground, colframe=cellborder]
\begin{Verbatim}[commandchars=\\{}]
sieht so aus, als wären da newlines reingekommen (vor der ascii-auswertung)
eliminate newline for esc??
newest quarto

View File

@ -23,7 +23,7 @@ local ANSI_COLORS = {
"ansi-white-intense"
}
--[[
local re = require "re"
local codes = {
@ -61,48 +61,57 @@ local ANSI = re.compile [[
'\x1b%[' {.*?} {[@-~]}
]]
function CodeBlock(e)
--]]
local s1, e1, c1, d1 = string.find(e.text, "\x1b%[(.-)([@-~])")
if s1 then
print(e.text)
print(s1, e1, c1, d1)
local function LaTeXconverter()
end
local function HTMLconverter(fg, bg, bold, underline, inverse)
if not (fg or bg or bold or underline or inverse) then
return "",""
end
local classes = {}
local styles = {}
if inverse then
fg, bg = bg, fg
end
if type(fg) == "number" then
table.insert(classes, ANSI_COLORS[fg] .. "-fg")
elseif fg then
table.insert("background-color: rgb(")
end
end
function CodeBlock(e)
if FORMAT:match 'latex' then
local converter = LaTeXconverter
elseif FORMAT:match 'html' then
local converter = HTMLconverter
elseif FORMAT:match 'native' then
local converter = HTMLconverter
else
return
end
if string.find(e.text, "\x1b%[") then
local text = e.text
local out = ""
while text do
s1, e1, c1, d1 = string.find(text, "\x1b%[(.-)([@-~])")
-- while text do
local 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
print(s1,numbers[1])
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