Skip to content

Commit

Permalink
fix(debug): Flatten content if necessary to process and debug location
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Aug 4, 2022
1 parent cc58824 commit c753bd2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
15 changes: 10 additions & 5 deletions classes/base.lua
Expand Up @@ -324,7 +324,8 @@ function class:registerCommands ()
self:registerCommand("include", function (options, content)
local packopts = packOptions(options)
if SU.hasContent(content) then
return SILE.processString(content[1], options.format, nil, packopts)
local doc = SU.contentToString(content)
return SILE.processString(doc, options.format, nil, packopts)
elseif options.src then
return SILE.processFile(options.src, options.format, packopts)
else
Expand All @@ -335,7 +336,8 @@ function class:registerCommands ()
self:registerCommand("lua", function (options, content)
local packopts = packOptions(options)
if SU.hasContent(content) then
return SILE.processString(content[1], "lua", nil, packopts)
local doc = SU.contentToString(content)
return SILE.processString(doc, "lua", nil, packopts)
elseif options.src then
return SILE.processFile(options.src, "lua", packopts)
elseif options.require then
Expand All @@ -349,7 +351,8 @@ function class:registerCommands ()
self:registerCommand("sil", function (options, content)
local packopts = packOptions(options)
if SU.hasContent(content) then
return SILE.processString(content[1], "sil")
local doc = SU.contentToString(content)
return SILE.processString(doc, "sil")
elseif options.src then
return SILE.processFile(options.src, "sil", packopts)
else
Expand All @@ -360,7 +363,8 @@ function class:registerCommands ()
self:registerCommand("xml", function (options, content)
local packopts = packOptions(options)
if SU.hasContent(content) then
return SILE.processString(content[1], "xml", nil, packopts)
local doc = SU.contentToString(content)
return SILE.processString(doc, "xml", nil, packopts)
elseif options.src then
return SILE.processFile(options.src, "xml", packopts)
else
Expand All @@ -371,7 +375,8 @@ function class:registerCommands ()
self:registerCommand("use", function (options, content)
local packopts = packOptions(options)
if content[1] and string.len(content[1]) > 0 then
SILE.processString(content[1], "lua", nil, packopts)
local doc = SU.contentToString(content)
SILE.processString(doc, "lua", nil, packopts)
else
if options.src then
SU.warn("Use of 'src' with \\use is discouraged because some of it's path handling\n will eventually be deprecated. Use 'module' instead when possible.")
Expand Down
1 change: 1 addition & 0 deletions core/tracestack.lua
Expand Up @@ -95,6 +95,7 @@ end

-- Push a document processing run (input method) onto the stack
function traceStack:pushDocument(file, doc)
if type(doc) == "table" then doc = tostring(doc) end
local snippet = doc:sub(1, 100)
local frame = traceStack.documentFrame(file, snippet)
return self:pushFrame(frame)
Expand Down
4 changes: 3 additions & 1 deletion core/utilities.lua
Expand Up @@ -307,7 +307,9 @@ end
utilities.contentToString = function (content)
local string = ""
for i = 1, #content do
if type(content[i]) == "string" then
if type(content[i]) == "table" and type(content[i][1]) == "string" then
string = string .. content[i][1]
elseif type(content[i]) == "string" then
string = string .. content[i]
end
end
Expand Down

0 comments on commit c753bd2

Please sign in to comment.