@@ -107,3 +107,40 @@ return {
107107 end,
108108 }
109109```
110+
111+### Extracting information about links
112+
113+This filter prints a table of all the URLs linked to
114+in the document, together with the number of links to
115+that URL.
116+
117+```lua
118+links = {}
119+
120+function Link (el)
121+ if links[el.target] then
122+ links[el.target] = links[el.target] + 1
123+ else
124+ links[el.target] = 1
125+ end
126+ return el
127+end
128+
129+function Doc (blocks, meta)
130+ function strCell(str)
131+ return {pandoc.Plain{pandoc.Str(str)}}
132+ end
133+ local caption = {pandoc.Str "Link", pandoc.Space(), pandoc.Str "count"}
134+ local aligns = {pandoc.AlignDefault, pandoc.AlignLeft}
135+ local widths = {0.8, 0.2}
136+ local headers = {strCell "Target", strCell "Count"}
137+ local rows = {}
138+ for link, count in pairs(links) do
139+ rows[#rows + 1] = {strCell(link), strCell(count)}
140+ end
141+ return pandoc.Doc(
142+ {pandoc.Table(caption, aligns, widths, headers, rows)},
143+ meta
144+ )
145+end
146+```