diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2013-06-04 15:44:44 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2013-06-04 15:44:44 +0200 |
commit | a3c01af8bbd581000e276cca076023c308bd688c (patch) | |
tree | d1939d4bdeb7302047da86105ba2677d30cf7337 /mod/tex/context/third/rst/rst_context.lua | |
parent | eb61b9fee9da56950cd05b7b5374f481a525276d (diff) | |
download | context-rst-a3c01af8bbd581000e276cca076023c308bd688c.tar.gz |
add inline images (non-float) via substitutions
Diffstat (limited to 'mod/tex/context/third/rst/rst_context.lua')
-rw-r--r-- | mod/tex/context/third/rst/rst_context.lua | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/mod/tex/context/third/rst/rst_context.lua b/mod/tex/context/third/rst/rst_context.lua index b9b9e58..c7e21fe 100644 --- a/mod/tex/context/third/rst/rst_context.lua +++ b/mod/tex/context/third/rst/rst_context.lua @@ -345,14 +345,14 @@ end function rst_context.substitution_reference (str, underscores) local sub = "" - rst_context.addsetups("substitutions") + rst_context.addsetups "substitutions" if underscores == "_" then -- normal reference sub = sub .. [[\\reference[__target_]] .. rst_context.whitespace_to_underscore(stringstrip(str)) .. "]{}" elseif underscores == "__" then -- normal reference rst_context.anonymous_targets = rst_context.anonymous_targets + 1 sub = sub .. [[\\reference[__target_anon_]] .. rst_context.anonymous_targets .. "]{}" end - return sub .. [[{\\RSTsubstitution]] .. str:gsub("%s", "") .. "}" + return sub .. [[{\\RSTsubstitution]] .. stringgsub(str, "%s", "") .. "}" end do @@ -1268,21 +1268,34 @@ function rst_context.footnote (label, content) return "" end +--- hack to differentiate inline images +local special_substitutions = { + image = "inline_image", +} + function rst_context.substitution_definition (subtext, directive, data) - local tmp - if data.first ~= "" then - tmp = { data.first } + local special = special_substitutions[directive] + if special then + --- override; pass data directly + directive = special else - tmp = { } - end - data.first = nil - for i=1, #data do -- paragraphs - local current = tableconcat(data[i], "\n") - --current = lpegmatch(inline_parser, current) - --current = rst_context.escape(current) - tmp[#tmp+1] = current + local tmp + if data.first ~= "" then + tmp = { data.first } + else + tmp = { } + end + data.first = nil + for i=1, #data do -- paragraphs + local current = tableconcat(data[i], "\n") + --current = lpegmatch(inline_parser, current) + --current = rst_context.escape(current) + tmp[#tmp+1] = current + end + data = tableconcat(tmp, "\n\n") + data = stringstrip(data) end - data = tableconcat(tmp, "\n\n") + subtext = stringgsub(subtext, "%s", "") rst_context.substitutions[subtext] = { directive = directive, data = data } return "" @@ -1290,7 +1303,7 @@ end -- not to be confused with the directive definition table rst_directives function rst_context.directive(directive, data) - local fun = rst_directives[directive] + local fun = rst_directives[directive] if fun then rst_context.addsetups("directive") local result = "" |