Annnd I figured it out about 15 minutes after I sent my original email. For anybody else who has this sort of problem, here is my solution: First, I have a function Div in my lua filter. Here's an excerpt:
function Div(element)
-- process other other kinds of divs...
elseif has_value(element.classes, 'character') then
local newelement = transform_character(element)
return newelement
end
return element
end
local function transform_character (element)
local i = 0
local newcontent = {}
for index, value in ipairs(element.content) do
i = i + 1
if value.tag == 'Para' and i > 1 then
if FORMAT == 'ms' then
table.insert (newcontent, pandoc.RawBlock ('ms', '.XP'))
table.insert (newcontent, pandoc.Plain (value.content))
else
io.stderr:write ('Transforming character elements not supported in '
.. FORMAT .. ' format, not transforming.\n')
table.insert (newcontent, value)
end
else
table.insert (newcontent, value)
end
end
local newDiv = pandoc.Div (newcontent)
return newDiv
end