Commits

Philipp Gesang committed 017b70c
  • Participants
  • Parent commits 31ec3b9

Comments (0)

Files changed (1)

mod/tex/context/third/rst/rst_directives.lua

     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
             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
 --}
 --]], 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