@@ -176,8 +176,25 @@ aside.footnote > .text > :first-child { margin-top: 0; } ]]; + docmeta = [[ + .render-warn { + border: 1px solid @tone(0.1 20); + background: @tone(0.4 20); + padding: 1em; + margin: 5em 1em; + } + ]]; + embed = [[ + embed, .embed { + width: 100%; + height: fit-content; + max-height: 80vh; + overflow: scroll; + } + embed {height: 20em;} + ]]; header = [[ body { padding: 0 2.5em !important } h1,h2,h3,h4,h5,h6 { border-bottom: 1px solid @tone(0.7); } h1 { font-size: 200%; border-bottom-style: double !important; border-bottom-width: 3px !important; margin: 0em -1em; } @@ -508,8 +525,14 @@ local runhook = function(h, ...) return renderJob:hook(h, render_state_handle, ...) end + + local function htmlentities(v) + return v:gsub('[<>&"]', function(x) + return string.format('&#%02u;', string.byte(x)) + end) + end local function htmlURI(uri) local family = uri:canfetch() if family == 'file' then @@ -632,11 +655,9 @@ local function htmlSpan(spans, block, sec) local text = {} for k,v in pairs(spans) do if type(v) == 'string' then - v=v:gsub('[<>&"]', function(x) - return string.format('&#%02u;', string.byte(x)) - end) + v=htmlentities(v) for fn, ext in renderJob:each('hook','render_html_sanitize') do v = fn(renderJob:delegate(ext), v) end table.insert(text,v) @@ -1000,12 +1021,15 @@ if s == nil then return {} elseif next(ctr) == nil then if (s.mode == 'embed' or s.mode == 'auto') and s.doc then + addStyle 'embed' ctr.tag = 'div'; -- kinda hacky, maybe fix + ctr.attrs = {class='embed'} ctr.nodes = renderSubdoc(s.doc) elseif s.mode == 'link' then -- yeah this is not gonna work my dude + addStyle 'embed' ctr.elt = 'embed'; ctr.attrs = { type = 'text/x.cortav'; src = htmlURI(s.uri); @@ -1017,11 +1041,14 @@ if s == nil then return {} elseif next(ctr) == nil then if (s.mode == 'embed' or s.mode == 'auto') and s.raw then + addStyle 'embed' ctr.tag = 'div' + ctr.attrs = {class='embed'} ctr.nodes = s.raw elseif s.mode == 'link' then + addStyle 'embed' ctr.elt = 'embed'; ctr.attrs = { type = 'text/html'; src = htmlURI(s.uri); @@ -1035,11 +1062,14 @@ elseif next(ctr) == nil then local mime = s.mime:clone() mime.opts={} if (s.mode == 'embed' or s.mode == 'auto') and s.raw then + addStyle 'embed' ctr.tag = 'pre'; - ctr.nodes = s.raw + ctr.attrs = {class='embed'} + ctr.nodes = htmlentities(s.raw); elseif s.mode == 'link' then + addStyle 'embed' ctr.elt = 'embed'; ctr.attrs = { type = tostring(mime); src = htmlURI(s.uri);