fix {wikilinks} in list items

This commit is contained in:
sejo 2022-04-03 14:41:50 -05:00
parent 1f49af73ce
commit e3eeba2877
1 changed files with 21 additions and 1 deletions

View File

@ -206,7 +206,14 @@ function firstPass()
out.web = string.format("%s<blockquote>%s</blockquote>", close, string.sub(line,3))
elseif string.match( line, "^%*") then -- LIST ITEMS
local li = string.format("<li>%s</li>", string.sub(line,3)) -- remove "* "
-- TODO reuse {wikilinks} code from paragraphs
-- web
local strippedline = string.sub(line, 3) -- remove "* "
local webtext = string.gsub( strippedline, "{(.-)}", function (wikiname)
return string.format("<a href='./%s.html'>%s</a>", pages[wikiname].slug, wikiname)
end)
local li = string.format("<li>%s</li>", webtext)
if not flags.list then -- start list
out.web = string.format("<ul>\n%s", li)
flags.list = true
@ -214,6 +221,19 @@ function firstPass()
out.web = li
end
-- gem
local gemlinks = {}
local gemline = string.gsub( line, "{(.-)}", function (wikiname)
table.insert(gemlinks, string.format("=> ./%s.gmi %s",pages[wikiname].slug, wikiname))
return wikiname
end)
out.gem = gemline
-- append links if there were any
if #gemlinks > 0 then
out.gem = out.gem.."\n"..table.concat(gemlinks,"\n")
end
elseif string.match( line, "^=>") then -- LINKS
local dest, text = getLink( line )
if string.match( dest, "^%./") then --local links