summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
Diffstat (limited to 'rst_context.lua')
-rw-r--r--rst_context.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/rst_context.lua b/rst_context.lua
index 5bc1753..1c050f9 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -173,6 +173,10 @@ function rst_context.anon_reference (str)
.. [=[]]=]
end
+local whitespace = S" \n\t\v"
+local nowhitespace = 1 - whitespace
+local removewhitespace = Cs((nowhitespace^1 + Cs(whitespace / ""))^0)
+
function rst_context.target (tab)
rst_context.addsetups("references")
--print("GOT ONE!")
@@ -190,13 +194,15 @@ function rst_context.target (tab)
local function create_anonymous ()
rst_context.anonymous_targets = rst_context.anonymous_targets + 1
- return "__target_anon_" .. rst_context.anonymous_targets
+ return "anon_" .. rst_context.anonymous_targets
end
target = resolve_indirect (target)
+ print(tab[1],target)
local insert = ""
+ --if removewhitespace:match(target) == "" then
if target == "" then -- links here
for _, id in next, tab do
insert = insert .. "\n\\reference[__target_" .. id .. "]{}"
@@ -204,8 +210,10 @@ function rst_context.target (tab)
else
for i=1,#tab do
local id = tab[i]:gsub("\\:",":"):match("`?([^`]+)`?") -- deescaping
- id = id ~= "" and id or create_anonymous ()
- refs[id] = refs[id] or target
+ if id then
+ id = id ~= "" and id or create_anonymous ()
+ refs[id] = refs[id] or target
+ end
end
end