10
10
11
11
local inventory = {}
12
12
13
- function lookup (search_object )
13
+ local function lookup (search_object )
14
14
15
15
local results = {}
16
- for ii , inventory in ipairs (inventory ) do
17
- for jj , item in ipairs (inventory .items ) do
16
+ for _ , inv in ipairs (inventory ) do
17
+ for _ , item in ipairs (inv .items ) do
18
18
-- e.g. :external+<inv_name>:<domain>:<role>:`<name>`
19
19
if item .inv_name and item .inv_name ~= search_object .inv_name then
20
20
goto continue
@@ -31,7 +31,9 @@ function lookup(search_object)
31
31
if search_object .domain and item .domain ~= search_object .domain then
32
32
goto continue
33
33
else
34
- table.insert (results , item )
34
+ if search_object .domain or item .domain == " py" then
35
+ table.insert (results , item )
36
+ end
35
37
36
38
goto continue
37
39
end
@@ -44,19 +46,17 @@ function lookup(search_object)
44
46
return results [1 ]
45
47
end
46
48
if # results > 1 then
47
- print (" Found multiple matches for " .. search_object .name )
48
- quarto .utils .dump (results )
49
- return nil
49
+ quarto .log .warning (" Found multiple matches for " .. search_object .name .. " , using the first match." )
50
+ return results [1 ]
50
51
end
51
52
if # results == 0 then
52
- print (" Found no matches for object:" )
53
- quarto .utils .dump (search_object )
53
+ quarto .log .warning (" Found no matches for object:\n " , search_object )
54
54
end
55
55
56
56
return nil
57
57
end
58
58
59
- function mysplit (inputstr , sep )
59
+ local function mysplit (inputstr , sep )
60
60
if sep == nil then
61
61
sep = " %s"
62
62
end
@@ -97,15 +97,15 @@ local function build_search_object(str)
97
97
search .role = normalize_role (t [3 ])
98
98
search .name = t [4 ]:match (" %%60(.*)%%60" )
99
99
else
100
- print (" couldn't parse this link: " .. str )
100
+ quarto . log . warning (" couldn't parse this link: " .. str )
101
101
return {}
102
102
end
103
103
else
104
104
search .name = str :match (" %%60(.*)%%60" )
105
105
end
106
106
107
107
if search .name == nil then
108
- print (" couldn't parse this link: " .. str )
108
+ quarto . log . warning (" couldn't parse this link: " .. str )
109
109
return {}
110
110
end
111
111
@@ -116,7 +116,7 @@ local function build_search_object(str)
116
116
return search
117
117
end
118
118
119
- function report_broken_link (link , search_object , replacement )
119
+ local function report_broken_link (link , search_object , replacement )
120
120
-- TODO: how to unescape html elements like [?
121
121
return pandoc .Code (pandoc .utils .stringify (link .content ))
122
122
end
@@ -154,7 +154,7 @@ function Link(link)
154
154
return link
155
155
end
156
156
157
- function fixup_json (json , prefix )
157
+ local function fixup_json (json , prefix )
158
158
for _ , item in ipairs (json .items ) do
159
159
item .uri = prefix .. item .uri
160
160
end
0 commit comments