@@ -9,9 +9,9 @@ local ct = require 'cortav' local ss = require 'sirsem' -- install rendering function for html -function ct.render.html(doc, opts) +function ct.render.html(doc, opts, setup) local doctitle = opts['title'] local f = string.format local getSafeID = ct.tool.namespace() @@ -420,8 +420,18 @@ stylesets_active = stylesNeeded; obj_htmlid = getSafeID; -- remaining fields added later } + + -- this is kind of gross but the context object belongs to the parser, + -- not the renderer, so that's not a suitable place for this information + doc.stage = { + kind = 'render'; + format = 'html'; + html_render_state = render_state_handle; + } + + setup(doc.stage) local renderJob = doc:job('render_html', nil, render_state_handle) doc.stage.job = renderJob; @@ -562,23 +572,11 @@ end end function span_renderers.var(v,b,s) - local val - if v.pos then - if not v.origin.invocation then - v.origin:fail 'positional arguments can only be used in a macro invocation' - elseif not v.origin.invocation.args[v.pos] then - v.origin.invocation.origin:fail('macro invocation %s missing positional argument #%u', v.origin.invocation.macro, v.pos) - end - val = v.origin.invocation.args[v.pos] - else - val = v.origin.doc:context_var(v.var, v.origin) - end - if v.raw then - return val - else - return htmlSpan(ct.parse_span(val, v.origin), b, s) + local r, raw = ct.expand_var(v) + if raw then return r else + return htmlSpan(r , b, s) end end function span_renderers.raw(v,b,s)