cortav  Diff

Differences From Artifact [c1f1be8e43]:

To Artifact [778a76ed09]:


     6      6   --    good both on a screen and when printed.
     7      7   --  > cortav -m render:format html
     8      8   
     9      9   local ct = require 'cortav'
    10     10   local ss = require 'sirsem'
    11     11   
    12     12   -- install rendering function for html
    13         -function ct.render.html(doc, opts)
           13  +function ct.render.html(doc, opts, setup)
    14     14   	local doctitle = opts['title']
    15     15   	local f = string.format
    16     16   	local getSafeID = ct.tool.namespace()
    17     17   
    18     18   	local footnotes = {}
    19     19   	local footnotecount = 0
    20     20   
................................................................................
   417    417   		style_rules = styles; -- use stylesneeded if at all possible
   418    418   		style_add = addStyle;
   419    419   		stylesets = stylesets;
   420    420   		stylesets_active = stylesNeeded;
   421    421   		obj_htmlid = getSafeID;
   422    422   		-- remaining fields added later
   423    423   	}
          424  +
          425  +	-- this is kind of gross but the context object belongs to the parser,
          426  +	-- not the renderer, so that's not a suitable place for this information
          427  +	doc.stage = {
          428  +		kind = 'render';
          429  +		format = 'html';
          430  +		html_render_state = render_state_handle;
          431  +	}
          432  +
          433  +	setup(doc.stage)
   424    434   
   425    435   	local renderJob = doc:job('render_html', nil, render_state_handle)
   426    436   	doc.stage.job = renderJob;
   427    437   
   428    438   	local runhook = function(h, ...)
   429    439   		return renderJob:hook(h, render_state_handle, ...)
   430    440   	end
................................................................................
   559    569   				end
   560    570   			else
   561    571   				b.origin:fail('%s is not an object that can be embedded', t.ref)
   562    572   			end
   563    573   		end
   564    574   
   565    575   		function span_renderers.var(v,b,s)
   566         -			local val
   567         -			if v.pos then
   568         -				if not v.origin.invocation then
   569         -					v.origin:fail 'positional arguments can only be used in a macro invocation'
   570         -				elseif not v.origin.invocation.args[v.pos] then
   571         -					v.origin.invocation.origin:fail('macro invocation %s missing positional argument #%u', v.origin.invocation.macro, v.pos)
   572         -				end
   573         -				val = v.origin.invocation.args[v.pos]
   574         -			else
   575         -				val = v.origin.doc:context_var(v.var, v.origin)
   576         -			end
   577         -			if v.raw then
   578         -				return val
   579         -			else
   580         -				return htmlSpan(ct.parse_span(val, v.origin), b, s)
          576  +			local r, raw = ct.expand_var(v)
          577  +			if raw then return r else
          578  +				return htmlSpan(r , b, s)
   581    579   			end
   582    580   		end
   583    581   
   584    582   		function span_renderers.raw(v,b,s)
   585    583   			return htmlSpan(v.spans, b, s)
   586    584   		end
   587    585