diff options
| author | Philipp Gesang <phg@phi-gamma.net> | 2013-06-03 14:38:36 +0200 | 
|---|---|---|
| committer | Philipp Gesang <phg@phi-gamma.net> | 2013-06-03 14:38:36 +0200 | 
| commit | 8b4ba148701a4a73819e49ba10b56a7125545d2c (patch) | |
| tree | 1b52bf1a6c11c9b22612163c620b47273fdfb253 /mod/tex | |
| parent | 55bd008f58be5880eb06975cd87e9d039c2b03d1 (diff) | |
| download | context-rst-8b4ba148701a4a73819e49ba10b56a7125545d2c.tar.gz | |
fix image directives
addresses: https://bitbucket.org/phg/context-rst/issue/1/image-directives-broken
Diffstat (limited to 'mod/tex')
| -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 | 
