anchor-aware refs in taskItem/itemItem/paragraphItem templates

This commit is contained in:
Zef Hemel
2026-04-30 19:47:47 +02:00
parent 46e8dcf112
commit dc6ee80ec8
@@ -15,19 +15,22 @@ templates.fullPageItem = template.new([==[
* [[${name}|${name}]]
]==])
-- Renders a task object as a togglable task
-- Renders a task object as a togglable task. Anchor refs are bare names
-- (no @ or #) — prefix them with $ so the resulting wikilink resolves
-- through the anchor index. Position/header refs already contain @ or #
-- and pass through unchanged.
templates.taskItem = template.new([==[
* [${state}] [[${ref}]] ${name}
* [${state}] [[${string.find(ref, "[@#]") and ref or "$" .. ref}]] ${name}
]==])
-- Renders an item object
templates.itemItem = template.new([==[
* [[${ref}]] ${name}
* [[${string.find(ref, "[@#]") and ref or "$" .. ref}]] ${name}
]==])
-- Renders a paragraph object
templates.paragraphItem = template.new([==[
* [[${ref}]] ${text}
* [[${string.find(ref, "[@#]") and ref or "$" .. ref}]] ${text}
]==])
-- Renders a tag object