From 8b4ba148701a4a73819e49ba10b56a7125545d2c Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 3 Jun 2013 14:38:36 +0200 Subject: fix image directives addresses: https://bitbucket.org/phg/context-rst/issue/1/image-directives-broken --- mod/tex/context/third/rst/rst_directives.lua | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'mod/tex/context') 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 -- cgit v1.2.3