diff options
-rw-r--r-- | mod/tex/context/third/rst/rst_directives.lua | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/mod/tex/context/third/rst/rst_directives.lua b/mod/tex/context/third/rst/rst_directives.lua index 374f942..d1be13b 100644 --- a/mod/tex/context/third/rst/rst_directives.lua +++ b/mod/tex/context/third/rst/rst_directives.lua @@ -78,18 +78,24 @@ rst_directives.image = function(data) local anon = false local rdi = rst_directives.images local hp = helpers.patterns + local caption = "" + local name - local name = stringstrip(data.name) + if data.name then + name = stringstrip(data.name) + data.name = nil + else + name = data[1] + end --rd.anonymous = rd.anonymous + 1 --anon = true -- indicates a nameless picture --name = "anonymous" .. rd.anonymous - properties.caption = name - data = tableflattened(data) + data = tableflattened(data) for i=1, #data do - local str = data[i] + local str = stringstrip(data[i]) local key, val = lpegmatch(hp.colon_keyval, str) if key and val then key = rdi.keys[key] -- sanitize key expression @@ -102,6 +108,12 @@ rst_directives.image = function(data) properties[key] = val end end + + if properties.caption then + caption = lpegmatch(inline_parser, properties.caption) + caption = rst_context.escape(caption) + end + properties.setup = img_setup(properties) or "" local img = "" -- local images_done = rdi.done @@ -119,10 +131,9 @@ rst_directives.image = function(data) --} --]], name, rst_context.escape(lpegmatch(inline_parser, properties.caption)), name, properties.setup) -- else -- image won't be referenced but used instantly - img = stringformat([[ - -\placefigure[here]{%s}{\externalfigure[%s]%s} -]], rst_context.escape(lpegmatch(inline_parser, properties.caption)), + img = stringformat( + "\n\\placefigure[here]{%s}{\\externalfigure[%s]%s}", + caption, name, properties.setup) -- end |