@@ -1151,8 +1151,11 @@ 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) @@ -1267,16 +1270,9 @@ 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 mime = ss.mime(args[2]); local class = mimeclasses[mime] table.insert(srcs, { mode = args[1]; mime = mime; @@ -1284,11 +1280,15 @@ 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 + -- 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