cortav  Diff

Differences From Artifact [4a60de4c59]:

To Artifact [e235e554e3]:


    55     55   			li {
    56     56   				padding: 0.1em 0;
    57     57   			}
    58     58   		]];
    59     59   		list_ordered = [[]];
    60     60   		list_unordered = [[]];
    61     61   		footnote = [[
           62  +			@media screen {
           63  +				a[href].fnref {
           64  +					text-decoration-style: dashed;
           65  +					color: @tone(0.7 45);
           66  +					text-decoration-color: @tone/0.4(0.7 45);
           67  +				}
           68  +				a[href]:hover.fnref {
           69  +					color: @tone(0.9 45);
           70  +					text-decoration-color: @tone/0.7(0.7 45);
           71  +				}
           72  +			}
    62     73   			aside.footnote {
    63     74   				font-family: 90%;
    64     75   				grid-template-columns: 1em 1fr min-content;
    65     76   				grid-template-rows: 1fr min-content;
    66     77   				position: fixed;
    67     78   				padding: 1em;
    68     79   				background: @tone(0.03);
................................................................................
    98    109   					backdrop-filter: blur(0px);
    99    110   				}
   100    111   				aside.footnote:target ~ #cover {
   101    112   					opacity: 100%;
   102    113   					pointer-events: all;
   103    114   					backdrop-filter: blur(5px);
   104    115   				}
          116  +			}
          117  +			@media screen and (max-width: calc(@width + 20em)) {
          118  +				aside.footnote {
          119  +					left: 1em;
          120  +					right: 1em;
          121  +				}
   105    122   			}
   106    123   			@media print {
   107    124   				aside.footnote {
   108    125   					display: grid;
   109    126   					position: relative;
   110    127   				}
   111    128   				aside.footnote:first-of-type {
................................................................................
   145    162   				}
   146    163   			}
   147    164   			aside.footnote > div.number {
   148    165   				text-align:right;
   149    166   				grid-row: 1/2;
   150    167   				grid-column: 1/2;
   151    168   			}
   152         -			aside.footnote > div.text {
          169  +			aside.footnote > .text {
   153    170   				grid-row: 1/2;
   154    171   				grid-column: 2/4;
   155    172   				padding-left: 1em;
   156    173   				overflow-y: auto;
          174  +				margin-top: 0;
   157    175   			}
   158         -			aside.footnote > div.text > p:first-child {
          176  +			aside.footnote > .text > :first-child {
   159    177   				margin-top: 0;
   160    178   			}
   161    179   		]];
   162    180   		header = [[
   163    181   			body { padding: 0 2.5em !important }
   164    182   			h1,h2,h3,h4,h5,h6 { border-bottom: 1px solid @tone(0.7); }
   165    183   			h1 { font-size: 200%; border-bottom-style: double !important; border-bottom-width: 3px !important; margin: 0em -1em; }
................................................................................
   761    779   		end
   762    780   		function span_renderers.footnote(f,b,s)
   763    781   			local linkattr = {}
   764    782   			if opts.epub then
   765    783   				linkattr['epub:type'] = 'noteref'
   766    784   			else
   767    785   				addStyle 'footnote'
          786  +				linkattr.class = 'fnref'
   768    787   			end
   769    788   			local source, sid, ssec = b.origin:ref(f.ref)
   770    789   			local cnc = getSafeID(ssec) .. ' ' .. sid
   771    790   			local fn
   772    791   			if footnotes[cnc] then
   773    792   				fn = footnotes[cnc]
   774    793   			else
................................................................................
   893    912   						table.insert(secnodes, block_renderers[bl.kind](bl,sec))
   894    913   					end
   895    914   				end
   896    915   				if next(secnodes) then
   897    916   					if doc.secorder[2] then --#secs>1?
   898    917   						-- only wrap in a section if >1 section
   899    918   						table.insert(ir, tag('section',
   900         -													{id = getSafeID(sec)},
   901         -													secnodes))
          919  +							{id = getSafeID(sec)},
          920  +							secnodes))
   902    921   					else
   903    922   						ir = secnodes
   904    923   					end
   905    924   				end
   906    925   			end
   907    926   			return ir
   908    927   		end
................................................................................
  1189   1208   	do local fnsorted = {}
  1190   1209   		for _, fn in pairs(footnotes) do
  1191   1210   			fnsorted[fn.num] = fn
  1192   1211   		end
  1193   1212   
  1194   1213   		for _, fn in ipairs(fnsorted) do
  1195   1214   			local tag = tagproc.toIR.tag
  1196         -			local body = {nodes={}}
  1197         -			local ftir = {}
  1198         -			for l in fn.source:gmatch('([^\n]*)') do
  1199         -				ct.parse_line(l, fn.origin, ftir)
         1215  +			local body
         1216  +			if type(fn.source) == 'table' then
         1217  +				if fn.source.kind == 'resource' then
         1218  +					local fake_embed = {
         1219  +						kind = 'embed';
         1220  +						rsrc = fn.source;
         1221  +						origin = fn.origin;
         1222  +						mode = 'inline';
         1223  +					}
         1224  +					local rendered = astproc.toIR.block_renderers.embed(
         1225  +						fake_embed, fn.origin.sec
         1226  +					)
         1227  +					if not rendered then
         1228  +						fn.origin:fail('unacceptable resource mime type “%s” for footnote target “%s”', fn.source.mime, fn.source.id or '(anonymous)')
         1229  +					end
         1230  +					body = rendered
         1231  +				else
         1232  +					fn.origin:fail('footnote span links to block “%s” of unacceptable kind “%s”', fn.source.kind)
         1233  +				end
         1234  +			else
         1235  +				body = {tag='div',nodes={}}
         1236  +				local ftir = {}
         1237  +				for l in fn.source:gmatch('([^\n]*)') do
         1238  +					ct.parse_line(l, fn.origin, ftir)
         1239  +				end
         1240  +				renderBlocks(ftir,body)
  1200   1241   			end
  1201         -			renderBlocks(ftir,body)
  1202   1242   			local fattr = {id=fn.id}
  1203   1243   			if opts.epub then
  1204   1244   				---UUUUUUGHHH
  1205   1245   				local npfx = string.format('(%u) ', fn.num)
  1206   1246   				if next(body.nodes) then
  1207   1247   					local n = body.nodes[1]
  1208   1248   					repeat
................................................................................
  1215   1255   						else
  1216   1256   							n.nodes[1] = {tag='p',attrs={},nodes={npfx}}
  1217   1257   							break
  1218   1258   						end
  1219   1259   					until false
  1220   1260   
  1221   1261   				else
  1222         -					body.nodes[1] = {tag='p',attrs={},nodes={npfx}}
         1262  +					if body.tag == 'div' then
         1263  +						body.nodes[1] = {tag='p',attrs={},nodes={npfx}}
         1264  +					elseif body.tag == 'pre' then
         1265  +						body.nodes[1] = npfx .. body.nodes[1]
         1266  +					else
         1267  +						body = {tag='div', nodes = {npfx, body}}
         1268  +					end
  1223   1269   				end
  1224   1270   				fattr['epub:type'] = 'footnote'
  1225   1271   			else
  1226   1272   				fattr.class = 'footnote'
  1227   1273   			end
         1274  +			body.attrs = body.attrs or {}
         1275  +			body.attrs.class = 'text'
  1228   1276   			local note = tag('aside', fattr, opts.epub and body.nodes or {
  1229   1277   				tag('div',{class='number'}, tostring(fn.num)),
  1230         -				tag('div',{class='text'}, body.nodes),
         1278  +				body,
         1279  +-- 				tag('div',{class='text'}, body.nodes),
  1231   1280   				tag('a',{href='#0'},'⤫')
  1232   1281   			})
  1233   1282   			table.insert(ir, note)
  1234   1283   		end
  1235   1284   	end
  1236   1285   	if next(footnotes) and not opts.epub then
  1237   1286   		table.insert(ir, tagproc.toIR.tag('div',{id='cover'},''))