first work on julia engine branch
This commit is contained in:
17
_extensions/MHellmund/julia-color/_extension.yml
Normal file
17
_extensions/MHellmund/julia-color/_extension.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
title: Julia-color
|
||||
author: Meik Hellmund
|
||||
version: 1.0.0
|
||||
quarto-required: ">=99.9.0"
|
||||
contributes:
|
||||
formats:
|
||||
common:
|
||||
filters:
|
||||
- "ansi2htmltex.lua"
|
||||
html:
|
||||
monofont: "JuliaMono"
|
||||
css:
|
||||
- "resources/css/ansicolor.css"
|
||||
- "resources/css/juliamono.css"
|
||||
pdf:
|
||||
include-in-header:
|
||||
- "resources/tex/juliainc.tex"
|
||||
@@ -1,10 +1,5 @@
|
||||
-- this is essentially
|
||||
-- based on
|
||||
-- https://github.com/jupyter/nbconvert/blob/main/nbconvert/filters/ansi.py
|
||||
-- converted to lua
|
||||
|
||||
-- good list of ANSI escape sequences:
|
||||
-- https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
|
||||
|
||||
|
||||
local ANSI_COLORS = {
|
||||
"ansi-black",
|
||||
@@ -60,18 +55,8 @@ local function get_extended_color(numbers)
|
||||
return {r, g, b}
|
||||
end
|
||||
|
||||
|
||||
--[=[
|
||||
local re = require "re"
|
||||
|
||||
local ANSI = re.compile [[
|
||||
'\x1b%[' {.*?} {[@-~]}
|
||||
]]
|
||||
|
||||
--]=]
|
||||
|
||||
local function LaTeXconverter(fg, bg, bold, underline, inverse)
|
||||
if not (fg or bg or bold or underline or inverse) then
|
||||
local function LaTeXconverter(fg, bg, bold, light, italic, underline, inverse)
|
||||
if not (fg or bg or bold or light or italic or underline or inverse) then
|
||||
return "",""
|
||||
end
|
||||
|
||||
@@ -116,6 +101,16 @@ local function LaTeXconverter(fg, bg, bold, underline, inverse)
|
||||
endtag = "}" .. endtag
|
||||
end
|
||||
|
||||
if light then
|
||||
starttag = starttag .. [[\textlight{]]
|
||||
endtag = "}" .. endtag
|
||||
end
|
||||
|
||||
if italic then
|
||||
starttag = starttag .. [[\textit{]]
|
||||
endtag = "}" .. endtag
|
||||
end
|
||||
|
||||
if underline then
|
||||
starttag = starttag .. [[\underline{]]
|
||||
endtag = "}" .. endtag
|
||||
@@ -123,8 +118,8 @@ local function LaTeXconverter(fg, bg, bold, underline, inverse)
|
||||
return starttag, endtag
|
||||
end
|
||||
|
||||
local function HTMLconverter(fg, bg, bold, underline, inverse)
|
||||
if not (fg or bg or bold or underline or inverse) then
|
||||
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 "",""
|
||||
end
|
||||
local classes = {}
|
||||
@@ -156,6 +151,14 @@ local function HTMLconverter(fg, bg, bold, underline, inverse)
|
||||
table.insert(classes, "ansi-bold")
|
||||
end
|
||||
|
||||
if light then
|
||||
table.insert(classes, "ansi-light")
|
||||
end
|
||||
|
||||
if italic then
|
||||
table.insert(classes, "ansi-italic")
|
||||
end
|
||||
|
||||
if underline then
|
||||
table.insert(classes, "ansi-underline")
|
||||
end
|
||||
@@ -196,7 +199,8 @@ local function codeBlockTrans(e)
|
||||
|
||||
local texenv="OutputCell"
|
||||
local codeclass=""
|
||||
if string.find(e.text, "\u{a35f}\u{2983}") then
|
||||
-- if string.find(e.text, "\u{a35f}\u{2983}") then
|
||||
if string.find(e.text, "\x1b%[") then
|
||||
texenv = "AnsiOutputCell"
|
||||
codeclass = "ansi"
|
||||
end
|
||||
@@ -206,12 +210,18 @@ local function codeBlockTrans(e)
|
||||
end
|
||||
|
||||
local out=""
|
||||
-- if string.find(e.text, "\x1b%[") then
|
||||
if string.find(e.text, "\u{a35f}\u{2983}") then
|
||||
local text = e.text
|
||||
|
||||
-- we remove links (eg in julia ParseErrors. THey link to local files, so they are useless anyway)
|
||||
text = text:gsub("\x1b%]8;.-\x1b\\", "")
|
||||
|
||||
if string.find(text, "\x1b%[") then
|
||||
-- if string.find(text, "\u{a35f}\u{2983}") then
|
||||
local bold = false
|
||||
local light = false
|
||||
local italic = false
|
||||
local underline = false
|
||||
local inverse = false
|
||||
local text = e.text
|
||||
local chunk = ""
|
||||
local fg = nil
|
||||
local bg = nil
|
||||
@@ -221,8 +231,9 @@ local function codeBlockTrans(e)
|
||||
|
||||
while text ~= "" do
|
||||
numbers = {}
|
||||
-- local s1, e1, c1, d1 = string.find(text, "\x1b%[(.-)([@-~])")
|
||||
local s1, e1, c1, d1 = string.find(text, "\u{a35f}\u{2983}(.-)([@-~])")
|
||||
-- [@-~]: matches single char between 64 and 126
|
||||
local s1, e1, c1, d1 = string.find(text, "\x1b%[(.-)([@-~])")
|
||||
-- local s1, e1, c1, d1 = string.find(text, "\u{a35f}\u{2983}(.-)([@-~])")
|
||||
if s1 then
|
||||
if d1 == "m" then
|
||||
for i in string.gmatch(c1, "([^;]*)") do
|
||||
@@ -238,9 +249,9 @@ local function codeBlockTrans(e)
|
||||
|
||||
if chunk ~= "" then
|
||||
if bold and type(fg)=="number" and fg<8 then
|
||||
starttag, endtag = converter(fg+8, bg, bold, underline, inverse)
|
||||
starttag, endtag = converter(fg+8, bg, bold, light, italic, underline, inverse)
|
||||
else
|
||||
starttag, endtag = converter(fg, bg, bold, underline, inverse)
|
||||
starttag, endtag = converter(fg, bg, bold, light, italic, underline, inverse)
|
||||
end
|
||||
out = out .. starttag .. chunk .. endtag
|
||||
end
|
||||
@@ -253,20 +264,26 @@ local function codeBlockTrans(e)
|
||||
bold = false
|
||||
inverse = false
|
||||
underline = false
|
||||
elseif n == 1 then
|
||||
elseif n == 1 or n == 5 or n == 6 then -- bold and blink
|
||||
bold = true
|
||||
elseif n == 2 or n == 8 then -- 'dim' and 'hide'
|
||||
light = true
|
||||
elseif n == 3 then
|
||||
italic = true
|
||||
elseif n == 4 then
|
||||
underline = true
|
||||
elseif n == 5 then
|
||||
bold = true -- 'blinking'
|
||||
elseif n == 7 then
|
||||
inverse = true
|
||||
elseif n == 21 or n == 22 then
|
||||
elseif n == 21 or n == 22 or n == 25 then
|
||||
bold = false
|
||||
elseif n == 23 then
|
||||
italic = false
|
||||
elseif n == 24 then
|
||||
underline = false
|
||||
elseif n == 27 then
|
||||
inverse = false
|
||||
elseif n == 22 or n == 28 then
|
||||
light = false
|
||||
elseif n >= 30 and n <= 37 then
|
||||
fg = n - 30
|
||||
elseif n == 38 then
|
||||
@@ -290,7 +307,7 @@ local function codeBlockTrans(e)
|
||||
end
|
||||
end
|
||||
else
|
||||
out = e.text
|
||||
out = text
|
||||
end
|
||||
if fmt == 'html' then
|
||||
return pandoc.RawBlock(fmt,
|
||||
@@ -324,67 +341,13 @@ local function divCodeBlockNoHeader1(e)
|
||||
for i, el in pairs(c) do
|
||||
if el.t == 'Header' then
|
||||
el.level = 6
|
||||
-- elneu = pandoc.Para(el.content)
|
||||
-- c[i] = elneu
|
||||
end
|
||||
if el.t == 'CodeBlock' then
|
||||
if el.classes:includes("jldoctest") then
|
||||
x,i = el.classes:find("jldoctest")
|
||||
el.classes:remove(i)
|
||||
end
|
||||
end
|
||||
end
|
||||
return e
|
||||
end
|
||||
|
||||
-- test if two divs should be merged
|
||||
local function testmerge(d1, d2)
|
||||
return d1 and d1.t == "Div" and d1.classes:includes("cell-output") and #d1.content == 1
|
||||
and d2 and d2.t == "Div" and d2.classes:includes("cell-output") and #d2.content == 1
|
||||
and d1.content[1].t == "CodeBlock" and not d1.classes:includes("cell-output-stderr")
|
||||
and d2.content[1].t == "CodeBlock" and not d2.classes:includes("cell-output-stderr")
|
||||
end
|
||||
|
||||
-- merge (div (codecell (text1)), div (codecell(text2))) to div(codecell(text1+text2))
|
||||
local function blockMerge(es)
|
||||
local nl = ""
|
||||
for i = #es-1, 1, -1 do
|
||||
if testmerge(es[i], es[i+1]) then
|
||||
str1 = es[i].content[1].text
|
||||
str2 = es[i+1].content[1].text
|
||||
nl = "\n"
|
||||
if es[i].classes:includes("cell-output-stdout") and es[i+1].classes:includes("cell-output-stdout") then
|
||||
if str1:sub(-1) == "\n" then
|
||||
nl = ""
|
||||
end
|
||||
if str2:sub(1, 1) == "\n" then
|
||||
nl = ""
|
||||
end
|
||||
end
|
||||
es[i].content[1].text = str1 .. nl .. str2
|
||||
es:remove(i+1)
|
||||
end
|
||||
end
|
||||
return es
|
||||
end
|
||||
|
||||
local function metaAdd(meta)
|
||||
--for key, val in pairs(PANDOC_READER_OPTIONS) do
|
||||
-- quarto.log.warning(key, val)
|
||||
--end
|
||||
quarto.doc.addHtmlDependency({name='ansicolors',
|
||||
stylesheets = {'resources/css/ansicolor.css'}})
|
||||
quarto.doc.addHtmlDependency({name='juliamonofont',
|
||||
stylesheets = {'resources/css/juliamono.css'}})
|
||||
if quarto.doc.isFormat('latex') then
|
||||
quarto.doc.include_file("in-header", "resources/juliainc.tex")
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{Div = divStderr},
|
||||
{Div = divCodeBlockNoHeader1},
|
||||
{Blocks = blockMerge},
|
||||
{CodeBlock = codeBlockTrans},
|
||||
{Meta = metaAdd}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
/* CSS added by ANSI escape sequences filter */
|
||||
|
||||
.ansi {
|
||||
/* line-height:1.15; */
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
@@ -46,5 +45,8 @@ pre .ansi-cyan-intense-bg { background-color: #258f8f; }
|
||||
pre .ansi-white-intense-bg { background-color: #a1a6b2; }
|
||||
pre .ansi-default-inverse-fg { color: rgba(255, 255, 255, 1); }
|
||||
pre .ansi-default-inverse-bg { background-color: #111111; }
|
||||
pre .ansi-bold { font-weight: bold; }
|
||||
pre .ansi-bold { font-weight: 800; }
|
||||
pre .ansi-light { font-weight: 300; }
|
||||
pre .ansi-italic { font-style: italic; }
|
||||
pre .ansi-underline { text-decoration: underline; }
|
||||
|
||||
110
_extensions/MHellmund/julia-color/resources/css/juliamono.css
Normal file
110
_extensions/MHellmund/julia-color/resources/css/juliamono.css
Normal file
@@ -0,0 +1,110 @@
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-Light.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-Regular.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-Medium.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-SemiBold.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-Bold.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 800;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-ExtraBold.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 900;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-Black.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
src: url("../fonts/JuliaMono-LightItalic.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 400;
|
||||
font-style: italic;
|
||||
src: url("../fonts/JuliaMono-RegularItalic.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 500;
|
||||
font-style: italic;
|
||||
src: url("../fonts/JuliaMono-MediumItalic.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 600;
|
||||
font-style: italic;
|
||||
src: url("../fonts/JuliaMono-SemiBoldItalic.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 700;
|
||||
font-style: italic;
|
||||
src: url("../fonts/JuliaMono-BoldItalic.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 800;
|
||||
font-style: italic;
|
||||
src: url("../fonts/JuliaMono-ExtraBoldItalic.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 900;
|
||||
font-style: italic;
|
||||
src: url("../fonts/JuliaMono-BlackItalic.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -8,9 +8,15 @@
|
||||
BoldFont = *-Bold,
|
||||
ItalicFont = *-RegularItalic,
|
||||
BoldItalicFont = *-BoldItalic,
|
||||
FontFace={l}{n}{Font=*-Light},
|
||||
FontFace={l}{it}{Font=*-LightItalic},
|
||||
Contextuals = AlternateOff,
|
||||
]
|
||||
|
||||
\DeclareRobustCommand{\lseries}{\fontseries{l}\selectfont}
|
||||
\DeclareTextFontCommand{\textlight}{\lseries}
|
||||
|
||||
|
||||
\DefineVerbatimEnvironment{OutputCell}{Verbatim}%
|
||||
{xleftmargin=1.5em}
|
||||
\DefineVerbatimEnvironment{AnsiOutputCell}{Verbatim}%
|
||||
@@ -35,4 +41,4 @@
|
||||
\definecolor{ansi-white}{HTML}{C5C1B4}
|
||||
\definecolor{ansi-white-intense}{HTML}{A1A6B2}
|
||||
\definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF}
|
||||
\definecolor{ansi-default-inverse-bg}{HTML}{000000}
|
||||
\definecolor{ansi-default-inverse-bg}{HTML}{000000}
|
||||
@@ -1,15 +0,0 @@
|
||||
title: Extensions for Julia
|
||||
author: Meik Hellmund
|
||||
version: 0.3.0
|
||||
contributes:
|
||||
format:
|
||||
common:
|
||||
filters:
|
||||
- ansi2htmltex.lua
|
||||
ipynb-filters:
|
||||
- escfilter.py
|
||||
pdf:
|
||||
default
|
||||
|
||||
html:
|
||||
monofont: "JuliaMono"
|
||||
@@ -1,5 +0,0 @@
|
||||
import sys
|
||||
f = sys.stdin.read()
|
||||
g = f.replace('\\u001b[','ꍟ⦃').replace('\\u001b]8;;','').replace('\\u001b\\\\','')
|
||||
sys.stdout.write(g)
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-Light.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-Regular.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-Medium.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-SemiBold.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-Bold.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 800;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-ExtraBold.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: JuliaMono;
|
||||
font-weight: 900;
|
||||
font-style: normal;
|
||||
src: url("../fonts/JuliaMono-Black.woff2") format("woff2");
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user