diff options
-rw-r--r-- | rst_context.lua | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/rst_context.lua b/rst_context.lua index 7712934..5bd16bd 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -90,11 +90,19 @@ function rst_context.addsetups(item) return 0 end +do + local w = S" \v\t\n" + local wp = Cs((w + 1)^1) + function rst_context.whitespace_to_underscore(str) + return wp:match(str) + end +end + -- So we can use crefs[n][2] to refer to the place where the reference was -- created. local function get_context_reference (str) local crefs = rst_context.context_references - refstring = "__contextref__" .. tostring(#crefs + 1) + refstring = "__target_" .. rst_context.whitespace_to_underscore(str) crefs[#crefs + 1] = { refstring, str } return refstring end @@ -140,7 +148,7 @@ end function rst_context.reference (str) str = str:match("[^_]*") - local link = rst_context.collected_references[str] + local link = rst_context.collected_references[str] or rst_context.context_references[str] if not link then -- assume internal return [[\\goto{]] .. str .. [[}[__target_]] .. str .. "]" end |