mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 08:25:32 +00:00
Fixes #4558. This makes a number of fixes to get the context help working correctly in Keyman 14: 1. Adds support for `redirect:` header in help .md files so that we can do redirects for the context content in Keyman for Windows help in the lua filters. 2. Renames Keyman for Windows help files to .htm, because that's what the .chm format is expecting, and what Delphi assumes for its .chm integration, and thus splits the html and htm lua filters. 3. Renames and makes more consistent the various context help pages. 4. Adds redirects for all pages that have sufficient content on other pages. 5. Fixes the instantiation of help in various Keyman for Windows forms. 6. Defaults to opening help from the Keyman source repo if the calling app is running in the source repo (this is just a development-side tweak that simplifies my life).
40 lines
1.2 KiB
Lua
40 lines
1.2 KiB
Lua
local redirect
|
|
|
|
function Link(elem)
|
|
if isLocalLink(elem) then
|
|
if isFolderLink(elem) then
|
|
return pandoc.Link(elem.content, elem.target .. 'index.htm', elem.title, elem.attr)
|
|
else
|
|
return pandoc.Link(elem.content, elem.target .. '.htm', elem.title, elem.attr)
|
|
end
|
|
end
|
|
return elem
|
|
end
|
|
|
|
function isLocalLink(elem)
|
|
return string.match(elem.target, "://") == nil
|
|
end
|
|
|
|
function isFolderLink(elem)
|
|
return not ( string.match(elem.target, "/$") == nil )
|
|
end
|
|
|
|
-- Support for redirect meta key, adds a meta refresh to the resulting document
|
|
function Meta(meta)
|
|
for k, v in pairs(meta) do
|
|
if k == 'redirect' and type(v) == 'table' and v.t == 'MetaInlines' then
|
|
redirect = v[1].c
|
|
end
|
|
end
|
|
return meta
|
|
end
|
|
|
|
function Pandoc(doc)
|
|
if redirect then
|
|
local metaRefresh = pandoc.RawBlock('html', "<meta http-equiv='refresh' content='0;url=" .. redirect .. ".htm'>")
|
|
local redirectText = pandoc.Para({pandoc.Str("This content can be found "), pandoc.Link("here", redirect .. ".htm"), pandoc.Str(".")})
|
|
table.insert(doc.blocks, metaRefresh)
|
|
table.insert(doc.blocks, redirectText)
|
|
end
|
|
return pandoc.Pandoc(doc.blocks, doc.meta)
|
|
end
|