Commits

Philipp Gesang  committed e1a1bf4

introduce inline text parsing to galleries

  • Participants
  • Parent commits 8bf750b

Comments (0)

Files changed (1)

File formatters/acceptor_f-mediawiki.lua

 end
 
 local process_inline = function (text, env)
+  if not text then return "" end
   text = pre_escape(text)
   text = lpegmatch(parsers.p_wiki_inline, text, 1, env)
   text = tableconcat(text)
   local entries         = { }
   local gallery_caption
   if raw.parameters then
-    local p = raw.parameters
-    gallery_caption = p.caption or ""
+    gallery_caption = raw.parameters.caption or ""
   end
   for i=1, nelements do
     local element    = raw[i]
-    local caption    = element.caption or ""
+    local caption    = process_inline(element.caption)
     local content
     if element.name then -- image
       local name       = gsub(element.name, " ", "_")
       end
       content = fmt(combination_externalfigure_template, image_name, 1 / nelements)
     else -- text
-      content = pre_escape(element.text)
-      content = lpegmatch(parsers.p_wiki_inline, content, 1, false)
-      content = tableconcat(content)
-      content = post_escape(content)
+      content = process_inline(element.text)
     end
     entries[i] = fmt(combination_entry_template, content, caption)
   end
+  gallery_caption = process_inline(gallery_caption)
   local result = fmt(combination_template,
                      "here",
                      "",
-                     gallery_caption or "",
+                     gallery_caption,
                      nelements .. "*1",
                      tableconcat(entries))
   return result