cortav  Diff

Differences From Artifact [2184d83e7b]:

To Artifact [ea1fbe20dd]:


449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
...
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
...
754
755
756
757
758
759
760

761
762
763
764
765
766
767
768
769
770
771


772
773
774
775
776
777
778
779
780
781
782
783
784
785
786

787


788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
	fns = {
		fork = function(me, name, pred, ...)
			-- generate a branch job linked to this job
			local branch = getmetatable(me)(name, me.doc, pred, ...)
			branch.parent = me
			return branch
		end;
		delegate = function(me, ext) -- creates a delegate for state access
			local submethods = {
				unwind = function(self, n)
					local function
					climb(dlg, job, n)
						if n == 0 then
							return job:delegate(dlg.extension)
						else
................................................................................
					return D.target[key]
				end;
				__newindex = function(self, key, value)
					local D = self._delegate_state
					if key == 'state' then
						D.target.states[D.extension] = value
					else
						D.target[D.extension] = value
					end
				end;
			});
			return d;
		end;
		each = function(me, ...)
			local ek
			local path = {...}
			return function()
				while true do
					ek = next(me.states, ek)
................................................................................
-- objects, including ones that users have not assigned IDs
-- to, and objects with the same name in different unlabeled
-- sections. to handle this, we provide a "namespace" mechanism,
-- 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
-- for every new object
	local ids = {}
	local canonicalID = {}
	return function(obj,pfx)
		pfx = pfx or ''
		if canonicalID[obj] then
			return canonicalID[obj]
................................................................................
			code = cp;
		}
	end
	ct.spanctls = {
		{seq = '!', parse = formatter 'emph'};
		{seq = '*', parse = formatter 'strong'};
		{seq = '~', parse = formatter 'strike'};

		{seq = '+', parse = formatter 'insert'};
		{seq = '\\', parse = function(s, c) -- raw
			return {
				kind = 'raw';
				spans = {s};
				origin = c:clone();
			}
		end};
		{seq = '`', parse = formatter 'literal'};
		{seq = '"', parse = rawcode};
		{seq = '$', parse = formatter 'variable'};


		{seq = '^', parse = function(s, c)
		-- TODO support for footnote sections
			local fn, t = s:match '^([^%s]+)%s*(.-)$'
			return {
				kind = 'footnote';
				spans = (t and t~='') and ct.parse_span(t, c) or {};
				ref = fn;
				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)]
				end
				return r
			end)
			local m = {s} --TODO
			return {
				kind = 'math';
				original = s;
				spans = {s};
				origin = c:clone();
			};







|







 







|


|
|







 







|







 







>











>
>











|
|
|
<
>
|
>
>
|
|
|
|
|
|
|
|







449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
...
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
...
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788

789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
	fns = {
		fork = function(me, name, pred, ...)
			-- generate a branch job linked to this job
			local branch = getmetatable(me)(name, me.doc, pred, ...)
			branch.parent = me
			return branch
		end;
		delegate = function(me, ext) -- creates a delegate for hierarchical state access
			local submethods = {
				unwind = function(self, n)
					local function
					climb(dlg, job, n)
						if n == 0 then
							return job:delegate(dlg.extension)
						else
................................................................................
					return D.target[key]
				end;
				__newindex = function(self, key, value)
					local D = self._delegate_state
					if key == 'state' then
						D.target.states[D.extension] = value
					else
						D.target[D.extension] = value -- FIXME?? is this right???
					end
				end;
			})
			return d
		end;
		each = function(me, ...)
			local ek
			local path = {...}
			return function()
				while true do
					ek = next(me.states, ek)
................................................................................
-- objects, including ones that users have not assigned IDs
-- to, and objects with the same name in different unlabeled
-- sections. to handle this, we provide a "namespace" mechanism,
-- 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 incrementsfile:///home/lexi/dev/cortav/build/cortav.html
-- for every new object
	local ids = {}
	local canonicalID = {}
	return function(obj,pfx)
		pfx = pfx or ''
		if canonicalID[obj] then
			return canonicalID[obj]
................................................................................
			code = cp;
		}
	end
	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';
				spans = {s};
				origin = c:clone();
			}
		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 {
				kind = 'footnote';
				spans = (t and t~='') and ct.parse_span(t, c) or {};
				ref = fn;
				origin = c:clone();
			}
		end};
		{seq = '=', parse = function(s,c) --math mode
			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
			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;
				spans = {s};
				origin = c:clone();
			};