1
0

filter cleanups

This commit is contained in:
Simon Michael
2023-11-30 15:22:48 -10:00
parent 42651ab844
commit eb8b829492
2 changed files with 5 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
-- Make all headings (except the page h1 added by page.tmpl) -- Make all headings (except the h1 added by page.tmpl)
-- clickable links to themselves, for easy bookmarking/linking. -- clickable links to themselves, for easy bookmarking/linking.
-- site.css controls their style.
function Header(el) function Header(el)
el.content = pandoc.Link(el.content, '#' .. el.identifier) el.content = pandoc.Link(el.content, '#' .. el.identifier)

View File

@@ -16,14 +16,15 @@ function Link(el)
-- t = t:gsub(t, "'", "") -- t = t:gsub(t, "'", "")
path, frag = t:match("([^#]*)#([^#]*)") path, frag = t:match("([^#]*)#([^#]*)")
t = path t = path
if path:len() > 0 and not ( if not (
path:len() == 0 or
path:match('%.html$') or path:match('%.html$') or
path:match('%.%.$') or path:match('%.%.$') or
path:match('/$') path:match('/$')
) then ) then
t = t .. ".html" t = t .. ".html"
end end
if string.len(frag) > 0 then if frag:len() > 0 then
frag = pandoc.text.lower(frag) frag = pandoc.text.lower(frag)
t = t .. "#" .. frag t = t .. "#" .. frag
end end