diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-12-10 14:46:33 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-12-10 14:46:33 -0800 |
commit | a0df2f676ca10bcabb3846308c162ed22a37aa22 (patch) | |
tree | 1debdfbb39df68aac70890fd1769ba45a8406f88 /tools | |
parent | a6297d252e0142d3da868fdf35206bba9fbedc4f (diff) | |
download | pandoc-a0df2f676ca10bcabb3846308c162ed22a37aa22.tar.gz |
Fix README.md so that relative links from manual become absolute.
Previously they'd be broken links when viewed on GitHub or Hackage.
So we add the base URL for the pandoc manual.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/update-readme.lua | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/tools/update-readme.lua b/tools/update-readme.lua index eabaf2285..38662d627 100644 --- a/tools/update-readme.lua +++ b/tools/update-readme.lua @@ -8,15 +8,21 @@ f:close() result = {} function Div(elem) - local ident = elem.identifier or "" - local get = function(el) - if el.identifier == ident then - result = el - end - end - if ident == 'input-formats' or ident == 'output-formats' then - pandoc.walk_block(pandoc.Div(mdoc.blocks), { Div = get }) - return result + local ident = elem.identifier or "" + local fixrel = function(el) + if el.target:match("^#") then + el.target = "https://pandoc.org/MANUAL.html" .. el.target end + return el + end + local get = function(el) + if el.identifier == ident then + result = pandoc.walk_block(el, { Link = fixrel }) + end + end + if ident == 'input-formats' or ident == 'output-formats' then + pandoc.walk_block(pandoc.Div(mdoc.blocks), { Div = get }) + return result + end end |