summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-14 00:21:26 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-14 00:21:26 +0200
commit7d02de72030797a5829f23c0ba87ebd157f044a1 (patch)
tree0ce5996cf2f90000104ec9fec5bd81cfb9e31559 /rst_context.lua
parent89746a438f5f65f969fb46105590a1c5d9c83423 (diff)
downloadcontext-rst-7d02de72030797a5829f23c0ba87ebd157f044a1.tar.gz
internal links now work
Diffstat (limited to 'rst_context.lua')
-rw-r--r--rst_context.lua28
1 files changed, 18 insertions, 10 deletions
diff --git a/rst_context.lua b/rst_context.lua
index c3ec323..7712934 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -141,8 +141,8 @@ end
function rst_context.reference (str)
str = str:match("[^_]*")
local link = rst_context.collected_references[str]
- if not link then -- TODO make warning instead
- return([[{\\sc UNDEFINED REFERENCE ]] .. str .. [[}.]])
+ if not link then -- assume internal
+ return [[\\goto{]] .. str .. [[}[__target_]] .. str .. "]"
end
return [[\\goto{]]
.. str
@@ -167,18 +167,26 @@ function rst_context.target (tab)
local function create_anonymous ()
rst_context.anonymous_links = rst_context.anonymous_links + 1
- return "__anon__" .. rst_context.anonymous_links
+ return "__target_anon_" .. rst_context.anonymous_links
end
-
target = resolve_indirect (target)
- for i=1,#tab do
- local id = tab[i]:gsub("\\:",":") -- deescaping
- id = id ~= "" and id or create_anonymous ()
- refs[id] = refs[id] or target
+ local insert = ""
+
+ if target == "" then -- links here
+ for _, id in next, tab do
+ insert = insert .. "\n\\reference[__target_" .. id .. "]{}"
+ end
+ else
+ for i=1,#tab do
+ local id = tab[i]:gsub("\\:",":") -- deescaping
+ id = id ~= "" and id or create_anonymous ()
+ refs[id] = refs[id] or target
+ end
end
- return ""
+
+ return insert
end
function rst_context.escape (str)
@@ -202,7 +210,7 @@ local inline_parser = P{
+ V"interpreted_text"
-- + V"inline_internal_target" -- TODO
+ V"reference"
- + V"footnote_reference" -- TODO
+ + V"footnote_reference"
-- + V"substitution_reference" -- TODO
+ V"link_standalone")
* V"succede_inline"),