cortav  Diff

Differences From Artifact [e235e554e3]:

To Artifact [28584fb71a]:


   173    173   				overflow-y: auto;
   174    174   				margin-top: 0;
   175    175   			}
   176    176   			aside.footnote > .text > :first-child {
   177    177   				margin-top: 0;
   178    178   			}
   179    179   		]];
          180  +		docmeta = [[
          181  +			.render-warn {
          182  +				border: 1px solid @tone(0.1 20);
          183  +				background: @tone(0.4 20);
          184  +				padding: 1em;
          185  +				margin: 5em 1em;
          186  +			}
          187  +		]];
          188  +		embed = [[
          189  +			embed, .embed {
          190  +				width: 100%;
          191  +				height: fit-content;
          192  +				max-height: 80vh;
          193  +				overflow: scroll;
          194  +			}
          195  +			embed {height: 20em;}
          196  +		]];
   180    197   		header = [[
   181    198   			body { padding: 0 2.5em !important }
   182    199   			h1,h2,h3,h4,h5,h6 { border-bottom: 1px solid @tone(0.7); }
   183    200   			h1 { font-size: 200%; border-bottom-style: double !important; border-bottom-width: 3px !important; margin: 0em -1em; }
   184    201   			h2 { font-size: 130%; margin: 0em -0.7em; }
   185    202   			h3 { font-size: 110%; margin: 0em -0.5em; }
   186    203   			h4 { font-size: 100%; font-weight: normal; margin: 0em -0.2em; }
................................................................................
   505    522   
   506    523   	local renderJob = doc:job('render_html', nil, render_state_handle)
   507    524   	doc.stage.job = renderJob;
   508    525   
   509    526   	local runhook = function(h, ...)
   510    527   		return renderJob:hook(h, render_state_handle, ...)
   511    528   	end
          529  +
          530  +	local function htmlentities(v)
          531  +		return v:gsub('[<>&"]', function(x)
          532  +			return string.format('&#%02u;', string.byte(x))
          533  +		end)
          534  +	end
   512    535   
   513    536   	local function htmlURI(uri)
   514    537   		local family = uri:canfetch()
   515    538   		if family == 'file' then
   516    539   			if uri.namespace == 'localhost' then
   517    540   				-- emit an actual file url
   518    541   				return 'file://' .. uri:construct('path','frag')
................................................................................
   629    652   				tag('body', nil, body or ''))
   630    653   		end
   631    654   
   632    655   		local function htmlSpan(spans, block, sec)
   633    656   			local text = {}
   634    657   			for k,v in pairs(spans) do
   635    658   				if type(v) == 'string' then
   636         -					v=v:gsub('[<>&"]', function(x)
   637         -							return string.format('&#%02u;', string.byte(x))
   638         -						end)
          659  +					v=htmlentities(v)
   639    660   					for fn, ext in renderJob:each('hook','render_html_sanitize') do
   640    661   						v = fn(renderJob:delegate(ext), v)
   641    662   					end
   642    663   					table.insert(text,v)
   643    664   				else
   644    665   					table.insert(text, (span_renderers[v.kind](v, block, sec)))
   645    666   				end
................................................................................
   997   1018   					end
   998   1019   				end};
   999   1020   				{ss.mime'text/x.cortav', function(s,ctr)
  1000   1021   					if s == nil then
  1001   1022   						return {}
  1002   1023   					elseif next(ctr) == nil then
  1003   1024   						if (s.mode == 'embed' or s.mode == 'auto') and s.doc then
         1025  +							addStyle 'embed'
  1004   1026   							ctr.tag = 'div'; -- kinda hacky, maybe fix
         1027  +							ctr.attrs = {class='embed'}
  1005   1028   							ctr.nodes = renderSubdoc(s.doc)
  1006   1029   						elseif s.mode == 'link' then
  1007   1030   							-- yeah this is not gonna work my dude
         1031  +							addStyle 'embed'
  1008   1032   							ctr.elt = 'embed';
  1009   1033   							ctr.attrs = {
  1010   1034   								type = 'text/x.cortav';
  1011   1035   								src = htmlURI(s.uri);
  1012   1036   							}
  1013   1037   						end
  1014   1038   					end
  1015   1039   				end};
  1016   1040   				{ss.mime'text/html',     function(s,ctr)
  1017   1041   					if s == nil then
  1018   1042   						return {}
  1019   1043   					elseif next(ctr) == nil then
  1020   1044   						if (s.mode == 'embed' or s.mode == 'auto') and s.raw then
         1045  +							addStyle 'embed'
  1021   1046   							ctr.tag = 'div'
         1047  +							ctr.attrs = {class='embed'}
  1022   1048   							ctr.nodes = s.raw
  1023   1049   						elseif s.mode == 'link' then
         1050  +							addStyle 'embed'
  1024   1051   							ctr.elt = 'embed';
  1025   1052   							ctr.attrs = {
  1026   1053   								type = 'text/html';
  1027   1054   								src = htmlURI(s.uri);
  1028   1055   							}
  1029   1056   						end
  1030   1057   					end
................................................................................
  1032   1059   				{ss.mime'text/*',     function(s,ctr)
  1033   1060   					if s == nil then
  1034   1061   						return {}
  1035   1062   					elseif next(ctr) == nil then
  1036   1063   						local mime = s.mime:clone()
  1037   1064   						mime.opts={}
  1038   1065   						if (s.mode == 'embed' or s.mode == 'auto') and s.raw then
         1066  +							addStyle 'embed'
  1039   1067   							ctr.tag = 'pre';
  1040         -							ctr.nodes = s.raw
         1068  +							ctr.attrs = {class='embed'}
         1069  +							ctr.nodes = htmlentities(s.raw);
  1041   1070   						elseif s.mode == 'link' then
         1071  +							addStyle 'embed'
  1042   1072   							ctr.elt = 'embed';
  1043   1073   							ctr.attrs = {
  1044   1074   								type = tostring(mime);
  1045   1075   								src = htmlURI(s.uri);
  1046   1076   							}
  1047   1077   						end
  1048   1078   					end