From a0df2f676ca10bcabb3846308c162ed22a37aa22 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 10 Dec 2019 14:46:33 -0800 Subject: 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. --- tools/update-readme.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'tools') 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 -- cgit v1.2.3