Skip to content

Commit 088a037

Browse files
committed
Simplify the nested if structure
1 parent ce06eef commit 088a037

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

inst/resources/lua/custom-environment.lua

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,13 @@ end
5252
-- Get metadata specific to bookdown for this filter
5353
Meta = function(m)
5454
bookdownmeta = m.bookdown
55-
if (bookdownmeta ~= nil) then
55+
if (bookdownmeta and bookdownmeta.language and bookdownmeta.language.label) then
5656
-- For internationalization feature of bookdown
57-
if (bookdownmeta.language ~= nil) then
58-
if (bookdownmeta.language.label ~= nil) then
59-
for k,v in pairs(bookdownmeta.language.label) do
60-
if (type(v) == 'table' and v.t == 'MetaInlines' and proof_label[k] ~= nil) then
61-
-- remove any undesired space (3 or less)
62-
proof_label[k] = pandoc.utils.stringify(v):gsub("%.?%s?%s?%s?$", "")
63-
print_debug("Translation-> "..k..":", proof_label[k])
64-
end
65-
end
57+
for k,v in pairs(bookdownmeta.language.label) do
58+
if (type(v) == 'table' and v.t == 'MetaInlines' and proof_label[k] ~= nil) then
59+
-- remove any undesired space (3 or less)
60+
proof_label[k] = pandoc.utils.stringify(v):gsub("%.?%s?%s?%s?$", "")
61+
print_debug("Translation-> "..k..":", proof_label[k])
6662
end
6763
end
6864
end

0 commit comments

Comments
 (0)