summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
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"),