I'm facing an issue when converting text with CSS styles inside HTML tags to DOCX. For example, <p style="text-align: center;">This text is centered.</p> is not being reflected correctly in the converted document.
One of the attempts to use the Lua filter with a reference DOCX document involved the following code:
function Para(elem)
if elem.attr and elem.attr.attributes and elem.attr.attributes.style then
local style = elem.attr.attributes.style
local align = style:match("text%-align:%s*([%w%-]+)")
if align then
elem.attr.classes:insert("align-" .. align)
end
end
return elem
end
,but without success.