cortav  Diff

Differences From Artifact [e235e554e3]:

To Artifact [28584fb71a]:


173
174
175
176
177
178
179

















180
181
182
183
184
185
186
...
505
506
507
508
509
510
511






512
513
514
515
516
517
518
...
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
...
997
998
999
1000
1001
1002
1003

1004

1005
1006
1007

1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020

1021

1022
1023

1024
1025
1026
1027
1028
1029
1030
....
1032
1033
1034
1035
1036
1037
1038

1039

1040
1041

1042
1043
1044
1045
1046
1047
1048
				overflow-y: auto;
				margin-top: 0;
			}
			aside.footnote > .text > :first-child {
				margin-top: 0;
			}
		]];

















		header = [[
			body { padding: 0 2.5em !important }
			h1,h2,h3,h4,h5,h6 { border-bottom: 1px solid @tone(0.7); }
			h1 { font-size: 200%; border-bottom-style: double !important; border-bottom-width: 3px !important; margin: 0em -1em; }
			h2 { font-size: 130%; margin: 0em -0.7em; }
			h3 { font-size: 110%; margin: 0em -0.5em; }
			h4 { font-size: 100%; font-weight: normal; margin: 0em -0.2em; }
................................................................................

	local renderJob = doc:job('render_html', nil, render_state_handle)
	doc.stage.job = renderJob;

	local runhook = function(h, ...)
		return renderJob:hook(h, render_state_handle, ...)
	end







	local function htmlURI(uri)
		local family = uri:canfetch()
		if family == 'file' then
			if uri.namespace == 'localhost' then
				-- emit an actual file url
				return 'file://' .. uri:construct('path','frag')
................................................................................
				tag('body', nil, body or ''))
		end

		local function htmlSpan(spans, block, sec)
			local text = {}
			for k,v in pairs(spans) do
				if type(v) == 'string' then
					v=v:gsub('[<>&"]', function(x)
							return string.format('&#%02u;', string.byte(x))
						end)
					for fn, ext in renderJob:each('hook','render_html_sanitize') do
						v = fn(renderJob:delegate(ext), v)
					end
					table.insert(text,v)
				else
					table.insert(text, (span_renderers[v.kind](v, block, sec)))
				end
................................................................................
					end
				end};
				{ss.mime'text/x.cortav', function(s,ctr)
					if s == nil then
						return {}
					elseif next(ctr) == nil then
						if (s.mode == 'embed' or s.mode == 'auto') and s.doc then

							ctr.tag = 'div'; -- kinda hacky, maybe fix

							ctr.nodes = renderSubdoc(s.doc)
						elseif s.mode == 'link' then
							-- yeah this is not gonna work my dude

							ctr.elt = 'embed';
							ctr.attrs = {
								type = 'text/x.cortav';
								src = htmlURI(s.uri);
							}
						end
					end
				end};
				{ss.mime'text/html',     function(s,ctr)
					if s == nil then
						return {}
					elseif next(ctr) == nil then
						if (s.mode == 'embed' or s.mode == 'auto') and s.raw then

							ctr.tag = 'div'

							ctr.nodes = s.raw
						elseif s.mode == 'link' then

							ctr.elt = 'embed';
							ctr.attrs = {
								type = 'text/html';
								src = htmlURI(s.uri);
							}
						end
					end
................................................................................
				{ss.mime'text/*',     function(s,ctr)
					if s == nil then
						return {}
					elseif next(ctr) == nil then
						local mime = s.mime:clone()
						mime.opts={}
						if (s.mode == 'embed' or s.mode == 'auto') and s.raw then

							ctr.tag = 'pre';

							ctr.nodes = s.raw
						elseif s.mode == 'link' then

							ctr.elt = 'embed';
							ctr.attrs = {
								type = tostring(mime);
								src = htmlURI(s.uri);
							}
						end
					end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>







 







|
<
<







 







>

>



>













>

>


>







 







>

>
|

>







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
...
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
...
652
653
654
655
656
657
658
659


660
661
662
663
664
665
666
....
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
....
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
				overflow-y: auto;
				margin-top: 0;
			}
			aside.footnote > .text > :first-child {
				margin-top: 0;
			}
		]];
		docmeta = [[
			.render-warn {
				border: 1px solid @tone(0.1 20);
				background: @tone(0.4 20);
				padding: 1em;
				margin: 5em 1em;
			}
		]];
		embed = [[
			embed, .embed {
				width: 100%;
				height: fit-content;
				max-height: 80vh;
				overflow: scroll;
			}
			embed {height: 20em;}
		]];
		header = [[
			body { padding: 0 2.5em !important }
			h1,h2,h3,h4,h5,h6 { border-bottom: 1px solid @tone(0.7); }
			h1 { font-size: 200%; border-bottom-style: double !important; border-bottom-width: 3px !important; margin: 0em -1em; }
			h2 { font-size: 130%; margin: 0em -0.7em; }
			h3 { font-size: 110%; margin: 0em -0.5em; }
			h4 { font-size: 100%; font-weight: normal; margin: 0em -0.2em; }
................................................................................

	local renderJob = doc:job('render_html', nil, render_state_handle)
	doc.stage.job = renderJob;

	local runhook = function(h, ...)
		return renderJob:hook(h, render_state_handle, ...)
	end

	local function htmlentities(v)
		return v:gsub('[<>&"]', function(x)
			return string.format('&#%02u;', string.byte(x))
		end)
	end

	local function htmlURI(uri)
		local family = uri:canfetch()
		if family == 'file' then
			if uri.namespace == 'localhost' then
				-- emit an actual file url
				return 'file://' .. uri:construct('path','frag')
................................................................................
				tag('body', nil, body or ''))
		end

		local function htmlSpan(spans, block, sec)
			local text = {}
			for k,v in pairs(spans) do
				if type(v) == 'string' then
					v=htmlentities(v)


					for fn, ext in renderJob:each('hook','render_html_sanitize') do
						v = fn(renderJob:delegate(ext), v)
					end
					table.insert(text,v)
				else
					table.insert(text, (span_renderers[v.kind](v, block, sec)))
				end
................................................................................
					end
				end};
				{ss.mime'text/x.cortav', function(s,ctr)
					if s == nil then
						return {}
					elseif next(ctr) == nil then
						if (s.mode == 'embed' or s.mode == 'auto') and s.doc then
							addStyle 'embed'
							ctr.tag = 'div'; -- kinda hacky, maybe fix
							ctr.attrs = {class='embed'}
							ctr.nodes = renderSubdoc(s.doc)
						elseif s.mode == 'link' then
							-- yeah this is not gonna work my dude
							addStyle 'embed'
							ctr.elt = 'embed';
							ctr.attrs = {
								type = 'text/x.cortav';
								src = htmlURI(s.uri);
							}
						end
					end
				end};
				{ss.mime'text/html',     function(s,ctr)
					if s == nil then
						return {}
					elseif next(ctr) == nil then
						if (s.mode == 'embed' or s.mode == 'auto') and s.raw then
							addStyle 'embed'
							ctr.tag = 'div'
							ctr.attrs = {class='embed'}
							ctr.nodes = s.raw
						elseif s.mode == 'link' then
							addStyle 'embed'
							ctr.elt = 'embed';
							ctr.attrs = {
								type = 'text/html';
								src = htmlURI(s.uri);
							}
						end
					end
................................................................................
				{ss.mime'text/*',     function(s,ctr)
					if s == nil then
						return {}
					elseif next(ctr) == nil then
						local mime = s.mime:clone()
						mime.opts={}
						if (s.mode == 'embed' or s.mode == 'auto') and s.raw then
							addStyle 'embed'
							ctr.tag = 'pre';
							ctr.attrs = {class='embed'}
							ctr.nodes = htmlentities(s.raw);
						elseif s.mode == 'link' then
							addStyle 'embed'
							ctr.elt = 'embed';
							ctr.attrs = {
								type = tostring(mime);
								src = htmlURI(s.uri);
							}
						end
					end