Skip to content

Commit 04467eb

Browse files
committed
feat(interlinks): support external part in lua filter
1 parent 8c529e7 commit 04467eb

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

_extensions/interlinks-experimental/interlinks.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function lookup(search_object)
1515
local results = {}
1616
for ii, inventory in ipairs(inventory) do
1717
for jj, item in ipairs(inventory.items) do
18+
-- e.g. :external+<inv_name>:<domain>:<role>:`<name>`
19+
if item.inv_name and item.inv_name ~= search_object.inv_name then
20+
goto continue
21+
end
22+
1823
if item.name ~= search_object.name then
1924
goto continue
2025
end
@@ -75,14 +80,23 @@ local function build_search_object(str)
7580
if starts_with_colon then
7681
local t = mysplit(str, ":")
7782
if #t == 2 then
83+
-- e.g. :py:func:`my_func`
7884
search.role = normalize_role(t[1])
7985
search.name = t[2]:match("%%60(.*)%%60")
8086
elseif #t == 3 then
87+
-- e.g. :py:func:`my_func`
8188
search.domain = t[1]
8289
search.role = normalize_role(t[2])
8390
search.name = t[3]:match("%%60(.*)%%60")
91+
elseif #t == 4 then
92+
-- e.g. :ext+inv:py:func:`my_func`
93+
search.external = true
94+
95+
search.inv_name = t[1]:match("external%+(.*)")
96+
search.domain = t[2]
97+
search.role = normalize_role(t[3])
98+
search.name = t[4]:match("%%60(.*)%%60")
8499
else
85-
-- TODO: handle external inventory files
86100
print("couldn't parse this link: " .. str)
87101
return {}
88102
end

quartodoc/tests/example_interlinks/test.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ output: [quartodoc.layout](/api/layout.html#quartodoc.layout)
141141

142142
## `` [](:external+other:py:function:`quartodoc.get_object`) ``
143143

144-
NOTE THAT THIS IS A FAILING TEST CASE
145-
146-
output: ``
144+
output:
145+
[quartodoc.get_object](other+api/get_object.html#quartodoc.get_object)
147146

148147
█─TestSpecEntry
149148
├─input = '[](:external+other:py:function:`quartodoc.get_obj ...

0 commit comments

Comments
 (0)