git.iko.soy/typeable/pandoc
on master help sign in
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.

commita0df2f676ca10bcabb3846308c162ed22a37aa22 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 10 Dec 2019, 14:46 (7 years ago) parenta6297d2
2 files changed+26−16
README.md+11−7 tools/update-readme.lua+15−9
README.md+11−7
@@ -39,8 +39,9 @@ library. It can convert *from*
3939 - `gfm` ([GitHub-Flavored
4040 Markdown](https://help.github.com/articles/github-flavored-markdown/)),
4141 or the deprecated and less accurate `markdown_github`; use
42− [`markdown_github`](#markdown-variants) only if you need extensions
43− not supported in [`gfm`](#markdown-variants).
42+ [`markdown_github`](https://pandoc.org/MANUAL.html#markdown-variants)
43+ only if you need extensions not supported in
44+ [`gfm`](https://pandoc.org/MANUAL.html#markdown-variants).
4445 - `haddock` ([Haddock
4546 markup](https://www.haskell.org/haddock/doc/html/ch03s08.html))
4647 - `html` ([HTML](http://www.w3.org/html/))
@@ -49,7 +50,8 @@ library. It can convert *from*
4950 - `jats` ([JATS](https://jats.nlm.nih.gov) XML)
5051 - `json` (JSON version of native AST)
5152 - `latex` ([LaTeX](http://latex-project.org))
52− - `markdown` ([Pandoc’s Markdown](#pandocs-markdown))
53+ - `markdown` ([Pandoc’s
54+ Markdown](https://pandoc.org/MANUAL.html#pandocs-markdown))
5355 - `markdown_mmd`
5456 ([MultiMarkdown](http://fletcherpenney.net/multimarkdown/))
5557 - `markdown_phpextra` ([PHP Markdown
@@ -98,8 +100,9 @@ It can convert *to*
98100 - `gfm` ([GitHub-Flavored
99101 Markdown](https://help.github.com/articles/github-flavored-markdown/)),
100102 or the deprecated and less accurate `markdown_github`; use
101− [`markdown_github`](#markdown-variants) only if you need extensions
102− not supported in [`gfm`](#markdown-variants).
103+ [`markdown_github`](https://pandoc.org/MANUAL.html#markdown-variants)
104+ only if you need extensions not supported in
105+ [`gfm`](https://pandoc.org/MANUAL.html#markdown-variants).
103106 - `haddock` ([Haddock
104107 markup](https://www.haskell.org/haddock/doc/html/ch03s08.html))
105108 - `html` or `html5` ([HTML](http://www.w3.org/html/),
@@ -118,7 +121,8 @@ It can convert *to*
118121 - `latex` ([LaTeX](http://latex-project.org))
119122 - `man` ([roff
120123 man](http://man7.org/linux/man-pages/man7/groff_man.7.html))
121− - `markdown` ([Pandoc’s Markdown](#pandocs-markdown))
124+ - `markdown` ([Pandoc’s
125+ Markdown](https://pandoc.org/MANUAL.html#pandocs-markdown))
122126 - `markdown_mmd`
123127 ([MultiMarkdown](http://fletcherpenney.net/multimarkdown/))
124128 - `markdown_phpextra` ([PHP Markdown
@@ -163,7 +167,7 @@ It can convert *to*
163167 - `zimwiki` ([ZimWiki
164168 markup](http://zim-wiki.org/manual/Help/Wiki_Syntax.html))
165169 - the path of a custom lua writer, see [Custom
166− writers](#custom-writers) below
170+ writers](https://pandoc.org/MANUAL.html#custom-writers) below
167171
168172</div>
169173
tools/update-readme.lua+15−9
@@ -8,15 +8,21 @@ f:close()
88result = {}
99
1010function Div(elem)
11− local ident = elem.identifier or ""
12− local get = function(el)
13− if el.identifier == ident then
14− result = el
15− end
16− end
17− if ident == 'input-formats' or ident == 'output-formats' then
18− pandoc.walk_block(pandoc.Div(mdoc.blocks), { Div = get })
19− return result
11+ local ident = elem.identifier or ""
12+ local fixrel = function(el)
13+ if el.target:match("^#") then
14+ el.target = "https://pandoc.org/MANUAL.html" .. el.target
2015 end
16+ return el
17+ end
18+ local get = function(el)
19+ if el.identifier == ident then
20+ result = pandoc.walk_block(el, { Link = fixrel })
21+ end
22+ end
23+ if ident == 'input-formats' or ident == 'output-formats' then
24+ pandoc.walk_block(pandoc.Div(mdoc.blocks), { Div = get })
25+ return result
26+ end
2127end
2228