From 6088fe9a225973f8311afaac9f82acb7bcd94ca0 Mon Sep 17 00:00:00 2001 From: Meik Hellmund Date: Wed, 21 Sep 2022 13:26:09 +0200 Subject: [PATCH] first commit --- .gitignore | 2 ++ Notes.txt | 33 +++++++++++++++++++++++++++++++++ ansi2html.lua | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 .gitignore create mode 100644 Notes.txt create mode 100644 ansi2html.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..47ef01f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*~ +*.ipynb diff --git a/Notes.txt b/Notes.txt new file mode 100644 index 0000000..54101f8 --- /dev/null +++ b/Notes.txt @@ -0,0 +1,33 @@ +pandoc -t native --ipynb-output=best 2_NumTypes.ipynb |jq + +quarto commit: +https://github.com/quarto-dev/quarto-cli/commit/2bd7b8719ecf8916f5754c0f3ac63ba5d7597c31 + +quarto discussion: +https://github.com/quarto-dev/quarto-cli/discussions/2488 + +pandoc discussion: +https://groups.google.com/g/pandoc-discuss/c/kFqvcZ1M8dw + +nbconvert filter: +https://github.com/jupyter/nbconvert/blob/main/nbconvert/filters/ansi.py + +ansi2html lib: +https://github.com/pycontribs/ansi2html/blob/main/ansi2html/converter.py + +https://pandoc.org/lua-filters.html + +pandoc commit ipynb-output-option +https://github.com/jgm/pandoc/commit/77faccb505992c944cd1b92f50e4e00d2927682b + +pandoc commit remove ansi escapes +https://github.com/jgm/pandoc/commit/5454aad32474472a8f977c941e6f7d70e925bcc5 + +https://github.com/jgm/pandoc/issues/5633 + +A filter example: +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 diff --git a/ansi2html.lua b/ansi2html.lua new file mode 100644 index 0000000..af0b6aa --- /dev/null +++ b/ansi2html.lua @@ -0,0 +1,38 @@ +local codes = { + -- attributes + reset = 0, + bright = 1, + dim = 2, + underscore = 4, + -- blink = 5, + reverse = 7, + -- hidden = 8, + + -- foreground + black = 30, + red = 31, + green = 32, + yellow = 33, + blue = 34, + magenta = 35, + cyan = 36, + white = 37, + + -- background + onblack = 40, + onred = 41, + ongreen = 42, + onyellow = 43, + onblue = 44, + onmagenta = 45, + oncyan = 46, + onwhite = 47, +} + + + +function CodeBlock(e) + if string.find(e.text, "\u{001b}\u{005b}", 1, true) then + print(e.text) + end +end \ No newline at end of file