Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions pandoc-ling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,42 @@ end

function getTrans (line)
if formatGloss then
-- remove quotes and add singlequote througout
if line[1].tag == "Quoted" then
line = line[1].content
-- Check if user provided their own quotes
if line[1] and line[1].tag == "Quoted" then
-- User provided quotes - preserve everything as-is
-- This allows users to manually handle citations and formatting
return pandoc.Plain(line)
end

-- No user quotes - apply automatic formatting
-- Extract trailing citations and spaces to place them outside the quotes
local citations = {}
local i = #line
while i >= 1 do
if line[i].tag == "Cite" or line[i].tag == "Space" then
table.insert(citations, 1, line[i])
i = i - 1
else
break
end
end

-- Remove extracted citations from line
for j = 1, #citations do
table.remove(line)
end

-- Quote the remaining content
line = pandoc.Quoted("SingleQuote", line)

-- Append citations after the quote
if #citations > 0 then
local result = {line}
for _, cite in ipairs(citations) do
table.insert(result, cite)
end
line = result
end
end
return pandoc.Plain(line)
end
Expand Down