cortav  Diff

Differences From Artifact [2184d83e7b]:

To Artifact [ea1fbe20dd]:


   449    449   	fns = {
   450    450   		fork = function(me, name, pred, ...)
   451    451   			-- generate a branch job linked to this job
   452    452   			local branch = getmetatable(me)(name, me.doc, pred, ...)
   453    453   			branch.parent = me
   454    454   			return branch
   455    455   		end;
   456         -		delegate = function(me, ext) -- creates a delegate for state access
          456  +		delegate = function(me, ext) -- creates a delegate for hierarchical state access
   457    457   			local submethods = {
   458    458   				unwind = function(self, n)
   459    459   					local function
   460    460   					climb(dlg, job, n)
   461    461   						if n == 0 then
   462    462   							return job:delegate(dlg.extension)
   463    463   						else
................................................................................
   485    485   					return D.target[key]
   486    486   				end;
   487    487   				__newindex = function(self, key, value)
   488    488   					local D = self._delegate_state
   489    489   					if key == 'state' then
   490    490   						D.target.states[D.extension] = value
   491    491   					else
   492         -						D.target[D.extension] = value
          492  +						D.target[D.extension] = value -- FIXME?? is this right???
   493    493   					end
   494    494   				end;
   495         -			});
   496         -			return d;
          495  +			})
          496  +			return d
   497    497   		end;
   498    498   		each = function(me, ...)
   499    499   			local ek
   500    500   			local path = {...}
   501    501   			return function()
   502    502   				while true do
   503    503   					ek = next(me.states, ek)
................................................................................
   611    611   -- objects, including ones that users have not assigned IDs
   612    612   -- to, and objects with the same name in different unlabeled
   613    613   -- sections. to handle this, we provide a "namespace" mechanism,
   614    614   -- where some lua table (really its address in memory) is used
   615    615   -- as a handle for the object and a unique ID is attached to it.
   616    616   -- if the object has an ID of its own, it is guaranteed to be
   617    617   -- unique and returned; otherwise, a generic id of the form
   618         --- `x-%u` is generated, where %u is an integer that increments
          618  +-- `x-%u` is generated, where %u is an integer that incrementsfile:///home/lexi/dev/cortav/build/cortav.html
   619    619   -- for every new object
   620    620   	local ids = {}
   621    621   	local canonicalID = {}
   622    622   	return function(obj,pfx)
   623    623   		pfx = pfx or ''
   624    624   		if canonicalID[obj] then
   625    625   			return canonicalID[obj]
................................................................................
   754    754   			code = cp;
   755    755   		}
   756    756   	end
   757    757   	ct.spanctls = {
   758    758   		{seq = '!', parse = formatter 'emph'};
   759    759   		{seq = '*', parse = formatter 'strong'};
   760    760   		{seq = '~', parse = formatter 'strike'};
          761  +		{seq = '_', parse = formatter 'underline'};
   761    762   		{seq = '+', parse = formatter 'insert'};
   762    763   		{seq = '\\', parse = function(s, c) -- raw
   763    764   			return {
   764    765   				kind = 'raw';
   765    766   				spans = {s};
   766    767   				origin = c:clone();
   767    768   			}
   768    769   		end};
   769    770   		{seq = '`', parse = formatter 'literal'};
   770    771   		{seq = '"', parse = rawcode};
   771    772   		{seq = '$', parse = formatter 'variable'};
          773  +		{seq = "'", parse = formatter 'super'};
          774  +		{seq = ',', parse = formatter 'sub'};
   772    775   		{seq = '^', parse = function(s, c)
   773    776   		-- TODO support for footnote sections
   774    777   			local fn, t = s:match '^([^%s]+)%s*(.-)$'
   775    778   			return {
   776    779   				kind = 'footnote';
   777    780   				spans = (t and t~='') and ct.parse_span(t, c) or {};
   778    781   				ref = fn;
   779    782   				origin = c:clone();
   780    783   			}
   781    784   		end};
   782    785   		{seq = '=', parse = function(s,c) --math mode
   783         -			local tx = {
   784         -				['%*'] = '×';
   785         -				['/'] = '÷';
   786         -			}
   787         -			for k,v in pairs(tx) do s = s:gsub(k,v) end
   788         -			s=s:gsub('%^([0-9]+)', function(num)
   789         -				local sup = {'⁰','¹','²','³','⁴','⁵','⁶','⁷','⁸','⁹'};
   790         -				local r = ''
   791         -				for i=1,#num do
   792         -					r = r .. sup[1 + (num:byte(i) - 0x30)]
          786  +			if c.doc.enc ~= ss.str.enc.ascii then
          787  +				for _,v in pairs(ss.compseq.math) do
          788  +					local seq, utf8, html, cp = table.unpack(v)
          789  +					seq = seq:gsub('[-+.*?[%]%%]', '%%%0') -- >_<
          790  +					s = s:gsub(seq,c.doc.enc.encodeUCS(utf8))
   793    791   				end
   794         -				return r
   795         -			end)
          792  +			end
          793  +-- 			s=s:gsub('%^([0-9]+)', function(num)
          794  +-- 				local sup = {'⁰','¹','²','³','⁴','⁵','⁶','⁷','⁸','⁹'};
          795  +-- 				local r = ''
          796  +-- 				for i=1,#num do
          797  +-- 					r = r .. sup[1 + (num:byte(i) - 0x30)]
          798  +-- 				end
          799  +-- 				return r
          800  +-- 			end)
   796    801   			local m = {s} --TODO
   797    802   			return {
   798    803   				kind = 'math';
   799    804   				original = s;
   800    805   				spans = {s};
   801    806   				origin = c:clone();
   802    807   			};