Skip to content

Commit 5b1375c

Browse files
committed
fix filter to use json interlinks
1 parent 6a74b2d commit 5b1375c

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

interlinks/_extensions/interlinks/interlinks.lua

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
inventory = {
2-
mutate = 'https://siuba.org/api/verbs-mutate-transmute/',
3-
['plotnine.positions.position.position'] = 'someurl'
4-
}
1+
inventory = {}
2+
traverse = 'topdown'
53

64
-- from https://stackoverflow.com/a/7615129/1144523
75
function str_split (inputstr, sep)
86
if sep == nil then
9-
sep = "%s"
7+
sep = "%s"
108
end
119
local t={}
1210
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
@@ -16,13 +14,25 @@ function str_split (inputstr, sep)
1614
end
1715

1816

17+
function Meta(meta)
18+
for k, v in pairs(meta.interlinks.sources) do
19+
local json = quarto.json.decode(read_file_contents(v.fallback))
20+
for inv_k, inv_v in pairs(json.items) do
21+
inventory[inv_v.name] = inv_v
22+
end
23+
end
24+
25+
-- print(quarto.utils.dump(inventory))
26+
27+
end
28+
29+
1930
-- Reformat all heading text
2031
function Header(el)
2132
el.content = pandoc.Emph(el.content)
2233
return el
2334
end
2435

25-
2636
function Code(el)
2737
if el.attr.classes:find("ref") == nil then
2838
return el
@@ -40,8 +50,11 @@ function Code(el)
4050
end
4151

4252
dst = inventory[ref_name]
53+
-- print(type(ref_name))
54+
-- print("DST ====")
55+
-- print(quarto.utils.dump(inventory))
4356
if dst ~= nil then
44-
return pandoc.Link(out_name, dst)
57+
return pandoc.Link(out_name, dst.uri)
4558
end
4659

4760
return el
@@ -59,20 +72,6 @@ function map(tbl, fn)
5972
return result
6073
end
6174

62-
local inventory = {}
63-
function Meta(meta)
64-
for k, v in pairs(meta.interlinks.sources) do
65-
print(k)
66-
print(pandoc.utils.stringify(v.fallback))
67-
local json = quarto.json.decode(read_file_contents(v.fallback))
68-
for inv_k, inv_v in pairs(json.items) do
69-
inventory[inv_v.name] = inv_v
70-
end
71-
end
72-
quarto.utils.dump(inventory)
73-
74-
end
75-
7675
function read_file_contents(file)
7776
local f = io.open(pandoc.utils.stringify(file), "r")
7877
if f == nil then

interlinks/example.qmd

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ interlinks:
88
url: https://siuba.org
99
inv: null
1010
fallback: objects_siuba.json
11+
vetiver:
12+
url: https://vetiver.rstudio.com
13+
inv: null
14+
fallback: objects_vetiver.json
1115
---
1216

1317
## Heading {#sec-hello}
@@ -16,8 +20,10 @@ interlinks:
1620

1721
Tilde means don't display module:
1822

19-
* `plotnine.positions.position.position`{.ref}
20-
* `~plotnine.positions.position.position`{.ref}
23+
* `vetiver.SKLearnHandler`{.ref}
24+
* `~vetiver.SKLearnHandler`{.ref}
25+
* `siuba:siuba.dply.verbs.mutate`{.ref}
26+
- TODO: should be able to use `domain:...` to use a specific inventory file.
2127
* `some explanation <mutate>`{.ref}
22-
* `some explanation <siuba:siuba.dply.verbs.mutate>`{.ref}
23-
* [some explanation](siuba:siuba.dply.verbs.mutate)
28+
- TODO: this syntax let's you change the text of the link.
29+
* [some explanation](vetiver.SKLearnHandler)

0 commit comments

Comments
 (0)