@@ -452,9 +452,9 @@ local branch = getmetatable(me)(name, me.doc, pred, ...) branch.parent = me return branch end; - delegate = function(me, ext) -- creates a delegate for state access + delegate = function(me, ext) -- creates a delegate for hierarchical state access local submethods = { unwind = function(self, n) local function climb(dlg, job, n) @@ -488,13 +488,13 @@ local D = self._delegate_state if key == 'state' then D.target.states[D.extension] = value else - D.target[D.extension] = value + D.target[D.extension] = value -- FIXME?? is this right??? end end; - }); - return d; + }) + return d end; each = function(me, ...) local ek local path = {...} @@ -614,9 +614,9 @@ -- where some lua table (really its address in memory) is used -- as a handle for the object and a unique ID is attached to it. -- if the object has an ID of its own, it is guaranteed to be -- unique and returned; otherwise, a generic id of the form --- `x-%u` is generated, where %u is an integer that increments +-- `x-%u` is generated, where %u is an integer that incrementsfile:///home/lexi/dev/cortav/build/cortav.html -- for every new object local ids = {} local canonicalID = {} return function(obj,pfx) @@ -757,8 +757,9 @@ ct.spanctls = { {seq = '!', parse = formatter 'emph'}; {seq = '*', parse = formatter 'strong'}; {seq = '~', parse = formatter 'strike'}; + {seq = '_', parse = formatter 'underline'}; {seq = '+', parse = formatter 'insert'}; {seq = '\\', parse = function(s, c) -- raw return { kind = 'raw'; @@ -768,8 +769,10 @@ end}; {seq = '`', parse = formatter 'literal'}; {seq = '"', parse = rawcode}; {seq = '$', parse = formatter 'variable'}; + {seq = "'", parse = formatter 'super'}; + {seq = ',', parse = formatter 'sub'}; {seq = '^', parse = function(s, c) -- TODO support for footnote sections local fn, t = s:match '^([^%s]+)%s*(.-)$' return { @@ -779,21 +782,23 @@ origin = c:clone(); } end}; {seq = '=', parse = function(s,c) --math mode - local tx = { - ['%*'] = '×'; - ['/'] = '÷'; - } - for k,v in pairs(tx) do s = s:gsub(k,v) end - s=s:gsub('%^([0-9]+)', function(num) - local sup = {'⁰','¹','²','³','⁴','⁵','⁶','⁷','⁸','⁹'}; - local r = '' - for i=1,#num do - r = r .. sup[1 + (num:byte(i) - 0x30)] + if c.doc.enc ~= ss.str.enc.ascii then + for _,v in pairs(ss.compseq.math) do + local seq, utf8, html, cp = table.unpack(v) + seq = seq:gsub('[-+.*?[%]%%]', '%%%0') -- >_< + s = s:gsub(seq,c.doc.enc.encodeUCS(utf8)) end - return r - end) + end +-- s=s:gsub('%^([0-9]+)', function(num) +-- local sup = {'⁰','¹','²','³','⁴','⁵','⁶','⁷','⁸','⁹'}; +-- local r = '' +-- for i=1,#num do +-- r = r .. sup[1 + (num:byte(i) - 0x30)] +-- end +-- return r +-- end) local m = {s} --TODO return { kind = 'math'; original = s;