summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-15 16:46:47 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-15 16:46:47 +0200
commitbe4f91df9499f6a6db891afbc680438795ce0606 (patch)
treea263fded7699ea9eea2832d751db914ef0016f2e /rst_context.lua
parent32b085252affd98e0c4ed4bb2ec0748579e6bb56 (diff)
downloadcontext-rst-be4f91df9499f6a6db891afbc680438795ce0606.tar.gz
substitutions now support hyperlinking
Diffstat (limited to 'rst_context.lua')
-rw-r--r--rst_context.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/rst_context.lua b/rst_context.lua
index d92a33d..f9eab29 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -157,7 +157,8 @@ function rst_context.anon_reference (str)
str = str:match("^`?([^`]+)`?__$")
rst_context.anonymous_links = rst_context.anonymous_links + 1
link = "__target_anon_" .. rst_context.anonymous_links
- return [[\\goto{]] .. str .. [[}[url(]] .. link .. [=[)]]=]
+ --return [[\\goto{]] .. str .. [[}[url(]] .. link .. [=[)]]=]
+ return string.format([[\\RSTchoosegoto{%s}{%s}]], link, str)
end
local whitespace = S" \n\t\v"
@@ -208,9 +209,16 @@ function rst_context.inline_internal_target (str)
return "\\\\reference[__target_" .. rst_context.whitespace_to_underscore(str) .."]{}"
end
-function rst_context.substitution_reference (str)
+function rst_context.substitution_reference (str, underscores)
+ local sub = ""
rst_context.addsetups("substitutions")
- return [[{\\RSTsubstitution]] .. str:gsub("%s", "") .. "}"
+ if underscores == "_" then -- normal reference
+ sub = sub .. [[\\reference[__target_]] .. rst_context.whitespace_to_underscore(string.strip(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", "") .. "}"
end
function rst_context.escape (str)
@@ -229,6 +237,7 @@ local inline_parser = P{
inline_element = Cs((V"strong_emphasis"
+ + V"substitution_reference"
+ V"anon_reference"
+ V"reference"
+ V"emphasis"
@@ -236,7 +245,6 @@ local inline_parser = P{
+ V"interpreted_text"
+ V"inline_internal_target"
+ V"footnote_reference"
- + V"substitution_reference"
+ V"link_standalone")
* V"succede_inline"),
@@ -398,7 +406,7 @@ local inline_parser = P{
substitution_reference = V"bar"
* C((1 - V"bar")^1)
* V"bar"
- * (V"underscore" + V"double_underscore")^-1
+ * C((V"double_underscore" + V"underscore")^-1)
/ rst_context.substitution_reference
,