liquid_feedback_frontend

diff env/format/wiki_text.lua @ 1045:701a5cf6b067

Imported LiquidFeedback Frontend 3.0 branch
author bsw
date Thu Jul 10 01:19:48 2014 +0200 (2014-07-10)
parents f49cdfb72567
children
line diff
     1.1 --- a/env/format/wiki_text.lua	Thu Jul 10 01:02:43 2014 +0200
     1.2 +++ b/env/format/wiki_text.lua	Thu Jul 10 01:19:48 2014 +0200
     1.3 @@ -1,12 +1,38 @@
     1.4  function format.wiki_text(wiki_text, formatting_engine)
     1.5 -  local formatting_engine = formatting_engine or "rocketwiki"
     1.6 +
     1.7 +  if not formatting_engine then
     1.8 +    error("Formatting engine identifier required")
     1.9 +  end
    1.10 +
    1.11 +  local fe
    1.12 +  
    1.13 +  for i, fe_entry in ipairs(config.formatting_engines) do
    1.14 +    if fe_entry.id == formatting_engine then
    1.15 +      fe = fe_entry
    1.16 +      break
    1.17 +    end
    1.18 +  end
    1.19 +
    1.20 +  if not fe then
    1.21 +    error("Formatting engine not found")
    1.22 +  end
    1.23 +  
    1.24    local html, errmsg, exitcode = assert(
    1.25 -    extos.pfilter(wiki_text, config.formatting_engine_executeables[formatting_engine])
    1.26 +    extos.pfilter(wiki_text, fe.executable, table.unpack(fe.args or {}))
    1.27    )
    1.28 +  
    1.29    if exitcode > 0 then
    1.30 +    trace.debug(html, errmsg)
    1.31      error("Wiki parser process returned with error code " .. tostring(exitcode))
    1.32    elseif exitcode < 0 then
    1.33 +    trace.debug(html, errmsg)
    1.34      error("Wiki parser process was terminated by signal " .. tostring(-exitcode))
    1.35    end
    1.36 +
    1.37 +  if fe.remove_images then
    1.38 +    html = string.gsub(html, '<img [^>]*>', '')
    1.39 +  end
    1.40 +  
    1.41    return html
    1.42 +  
    1.43  end

Impressum / About Us