cortav  Diff

Differences From Artifact [bf3719fe9a]:

To Artifact [c52f4282f5]:


1148
1149
1150
1151
1152
1153
1154



1155
1156
1157
1158
1159
1160
1161
....
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290






1291
1292
1293
1294
1295
1296
1297
	{fn = insert_paragraph};
}

function ct.parse_line(l, ctx, dest)
	local newspan
	local job = ctx.doc.stage.job
	job:hook('line_read',ctx,l)



	if ctx.mode then
		if ctx.mode.kind == 'code' then
			if l and l:match '^~~~%s*$' then
				job:hook('block_listing_end',ctx,ctx.mode.listing)
				job:hook('mode_switch', c, nil)
				ctx.mode = nil
			else
................................................................................
				local lines = ss.str.breaklines(ctx.doc.enc, r.props.src)
				local srcs = {}
				for i,l in ipairs(lines) do
					local args = ss.str.breakwords(ctx.doc.enc, l, 2, {escape=true})
					if #args < 3 then
						r.origin:fail('invalid syntax for resource %s', t.ref)
					end
					local mimebreak = function(s)
						local wds = ss.str.split(ctx.doc.enc, s, '/', 1, {escape=true})
						return wds
					end
					local mime = mimebreak(args[2]);
					local mimeclasses = {
						['application/svg+xml'] = 'image';
					}
					local class = mimeclasses[mime]
					table.insert(srcs, {
						mode = args[1];
						mime = mime;
						uri = args[3];
						class = class or mime[1];
					})
				end
				 --ideally move this into its own mimetype lib
				local kind = r.props.as or srcs[1].class
				r.class = kind
				r.srcs = srcs






			end
		end
	end
	ctx.doc.stage = nil
	ctx.doc.docjob:hook('meddle_ast')
	return ctx.doc
end







>
>
>







 







<
<
<
<
|
<
<
<









<
<

>
>
>
>
>
>







1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
....
1267
1268
1269
1270
1271
1272
1273




1274



1275
1276
1277
1278
1279
1280
1281
1282
1283


1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
	{fn = insert_paragraph};
}

function ct.parse_line(l, ctx, dest)
	local newspan
	local job = ctx.doc.stage.job
	job:hook('line_read',ctx,l)
	if l then
		l = l:gsub("^ +","") -- trim leading spaces
	end
	if ctx.mode then
		if ctx.mode.kind == 'code' then
			if l and l:match '^~~~%s*$' then
				job:hook('block_listing_end',ctx,ctx.mode.listing)
				job:hook('mode_switch', c, nil)
				ctx.mode = nil
			else
................................................................................
				local lines = ss.str.breaklines(ctx.doc.enc, r.props.src)
				local srcs = {}
				for i,l in ipairs(lines) do
					local args = ss.str.breakwords(ctx.doc.enc, l, 2, {escape=true})
					if #args < 3 then
						r.origin:fail('invalid syntax for resource %s', t.ref)
					end




					local mime = ss.mime(args[2]);



					local class = mimeclasses[mime]
					table.insert(srcs, {
						mode = args[1];
						mime = mime;
						uri = args[3];
						class = class or mime[1];
					})
				end
				 --ideally move this into its own mimetype lib


				r.srcs = srcs
				-- note that resources do not themselves have kinds. when a
				-- document requests to insert a resource, the renderer must
				-- iterate through the sources and find the first source it
				-- is capable of emitting. this allows constructions like
				-- emitting a video for HTML outputs, a photo for printers,
				-- and a screenplay for tty/plaintext outputs.
			end
		end
	end
	ctx.doc.stage = nil
	ctx.doc.docjob:hook('meddle_ast')
	return ctx.doc
end