cortav  Diff

Differences From Artifact [cf364bf145]:

To Artifact [70cf5fbd0d]:


   362    362   			section > figure.listing > hr {
   363    363   				border: none;
   364    364   				margin: 0;
   365    365   				height: 0.7em;
   366    366   				counter-increment: line-number;
   367    367   			}
   368    368   		]];
          369  +		toc = [[
          370  +
          371  +		]];
          372  +		tocFixed = [[
          373  +			@media (min-width: calc(@[width]:[100vw] + 20em)) {
          374  +				ol.toc {
          375  +					position: fixed;
          376  +					padding-top: 1em; padding-bottom: 1em;
          377  +					padding-right: 1em;
          378  +					margin-top: 0; margin-bottom: 0;
          379  +					right: 0; top: 0; bottom: 0;
          380  +					max-width: calc(50vw - ((@[width]:[0]) / 2) - 3.5em);
          381  +					overflow-y: auto;
          382  +				}
          383  +				@media (max-width: calc(@[width]:[100vw] + 30em)) {
          384  +					ol.toc {
          385  +						max-width: calc(100vw - ((@[width]:[0])) - 9.5em);
          386  +					}
          387  +					body {
          388  +						margin-left: 5em;
          389  +					}
          390  +				}
          391  +			}
          392  +		]];
   369    393   	}
   370    394   
   371    395   	local stylesNeeded = {}
   372    396   
   373    397   	local function getSpanRenderers(tag,elt)
   374    398   		local htmlDoc = function(title, head, body)
   375    399   			return [[<!doctype html>]] .. tag('html',nil,
................................................................................
   467    491   			htmlDoc = htmlDoc;
   468    492   		}
   469    493   	end
   470    494   
   471    495   
   472    496   	local function getBlockRenderers(tag,elt,sr,catenate)
   473    497   		local function insert_toc(b,s)
   474         -			local lst = {tag = 'ol', attrs={}, nodes={}}
          498  +			local lst = {tag = 'ol', attrs={class='toc'}, nodes={}}
          499  +			stylesNeeded.toc = true
          500  +			if opts['width'] then
          501  +				stylesNeeded.tocFixed = true
          502  +			end
   475    503   			local stack = {lst}
   476    504   			local top = function() return stack[#stack] end
   477    505   			local all = s.origin.doc.secorder
   478    506   			for i, sec in ipairs(all) do
   479    507   				if sec.heading_node then
   480    508   					local ent = tag('li',nil,
   481    509   						 catenate{tag('a', {href='#'..getSafeID(sec)},
................................................................................
   757    785   					l,sep,sat = param:match('^%('..string.rep('([^%s]*)%s*',i)..'%)$')
   758    786   					if l then break end
   759    787   				end
   760    788   				l = ss.math.lerp(tonumber(l), tbg, tfg)
   761    789   				return tone(l, tonumber(sat), tonumber(sep), tonumber(alpha))
   762    790   			end
   763    791   		end
          792  +		css = css:gsub('@(%b[]):(%b[])', function(v,d) return opts[v:sub(2,-2)] or v:sub(2,-2) end)
   764    793   		css = css:gsub('@(%w+)/([0-9.]+)(%b())', replace)
   765    794   		css = css:gsub('@(%w+)(%b())', function(a,b) return replace(a,nil,b) end)
   766    795   		css = css:gsub('@(%w+)/([0-9.]+)', replace)
   767    796   		css = css:gsub('@(%w+)', function(a,b) return replace(a,nil,b) end)
   768    797   		return (css:gsub('%s+',' '))
   769    798   	end
   770    799