Skip to content

Commit 20e6279

Browse files
authored
code review: do not use nested, named function() declarations (#4658)
* code review: do not use nested, named function() declarations
1 parent 383aa2a commit 20e6279

File tree

13 files changed

+31
-31
lines changed

13 files changed

+31
-31
lines changed

src/resources/filters/ast/emulatedfilter.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Copyright (C) 2022 by RStudio, PBC
55

66
local function plain_loader(handlers)
7-
function wrapFilter(handler)
7+
local function wrapFilter(handler)
88
local wrappedFilter = {}
99
wrappedFilter.scriptFile = handler.scriptFile
1010
for k, v in pairs(handler) do

src/resources/filters/ast/wrappedwriter.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function wrapped_writer()
104104
end
105105
}
106106

107-
function handleBottomUpResult(v)
107+
local function handleBottomUpResult(v)
108108
if type(v) == "string" then
109109
table.insert(resultingStrs, v)
110110
elseif type(v) == "userdata" then

src/resources/filters/common/meta.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ end
5050

5151
function metaInjectLatex(meta, func)
5252
if _quarto.format.isLatexOutput() then
53-
function inject(tex)
53+
local function inject(tex)
5454
addInclude(meta, "tex", kHeaderIncludes, tex)
5555
end
5656
inject("\\makeatletter")
@@ -69,7 +69,7 @@ end
6969

7070
function metaInjectRawLatex(meta, include, func)
7171
if _quarto.format.isLatexOutput() then
72-
function inject(tex)
72+
local function inject(tex)
7373
addInclude(meta, "tex", include, tex)
7474
end
7575
func(inject)
@@ -79,7 +79,7 @@ end
7979

8080
function metaInjectHtml(meta, func)
8181
if _quarto.format.isHtmlOutput() then
82-
function inject(html)
82+
local function inject(html)
8383
addInclude(meta, "html", kHeaderIncludes, html)
8484
end
8585
func(inject)

src/resources/filters/common/refs.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function hasSubRefs(divEl, type)
6868
if hasFigureOrTableRef(divEl) and not hasRefParent(divEl) then
6969
-- children w/ parent id
7070
local found = false
71-
function checkForParent(el)
71+
local function checkForParent(el)
7272
if not found then
7373
if hasRefParent(el) then
7474
if not type or (refType(el.attr.identifier) == type) then

src/resources/filters/common/timing.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function capture_timings(filterList, trace)
4040
for key,func in pairs(v) do
4141
newFilter[key] = func
4242
end
43-
function makeNewFilter(oldPandoc)
43+
local function makeNewFilter(oldPandoc)
4444
return function (p)
4545
if oldPandoc ~= nil then
4646
local result = oldPandoc(p)

src/resources/filters/common/wrapped-filter.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function makeWrappedLuaFilter(scriptFile, filterHandler)
113113
local chunk, err = loadfile(scriptFile, "bt", env)
114114
local handlers = {}
115115

116-
function makeSingleHandler(handlerTable)
116+
local function makeSingleHandler(handlerTable)
117117
local result = {}
118118
setmetatable(result, {
119119
__index = { scriptFile = scriptFile }

src/resources/filters/crossref/format.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function formatNumberOption(type, order, default)
129129
end
130130

131131
-- return a pandoc.Str w/ chapter prefix (if any)
132-
function resolve(num)
132+
local function resolve(num)
133133
if section then
134134
local sectionIndex = section[1]
135135
if crossrefOption("chapters-alpha", false) then

src/resources/filters/crossref/tables.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ end
4343

4444
function preprocessRawTableBlock(rawEl, parentId)
4545

46-
function divWrap(el, label, caption)
46+
local function divWrap(el, label, caption)
4747
local div = pandoc.Div(el, pandoc.Attr(label))
4848
if parentId then
4949
div.attr.attributes[kRefParent] = parentId

src/resources/filters/layout/layout.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function layoutCells(divEl, cells)
202202

203203
-- manage/perform next insertion into the layout
204204
local cellIndex = 1
205-
function layoutNextCell(width)
205+
local function layoutNextCell(width)
206206
-- check for a spacer width (negative percent)
207207
if isSpacerWidth(width) then
208208
local cell = pandoc.Div({

src/resources/filters/qmd-reader.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function find_invalid_tags(str)
3737
"^[ \t\f\v]*(```+[ \t\f\v]*)(%{+[^.=\n\r]*%}+)",
3838
"\n[ \t\f\v]*(```+[ \t\f\v]*)(%{+[^.=\n\r]+%}+)"
3939
}
40-
function find_it(init)
40+
local function find_it(init)
4141
for _, pattern in ipairs(patterns) do
4242
local range_start, range_end, ticks, tag = str:find(pattern, init)
4343
if range_start ~= nil then
@@ -119,7 +119,7 @@ function Reader (inputs, opts)
119119
format = "markdown",
120120
extensions = extensions,
121121
}
122-
function restore_invalid_tags(tag)
122+
local function restore_invalid_tags(tag)
123123
return tags[tag] or tag
124124
end
125125
local doc = pandoc.read(txt, flavor, opts):walk {

0 commit comments

Comments
 (0)