Skip to content

Issue converting CSS styles to HTML tags for DOCX; paragraphs are not retaining the corresponding styles during conversion. #10872

@AndreCOLI

Description

@AndreCOLI

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions