Skip to content

Docx reader ignores underline types other than single (double, thick, dotted, wave, words, …) #11988

Open

Description

@patrick-5546

The docx reader reads a run as Underline only when w:u has w:val="single". Other underline types are dropped without a warning, even though Word shows them all as underlined text: double, thick, dotted, dash, wave, words and the rest of ST_Underline.

Reproduction

underline.py writes a one-paragraph underline.docx with one run for each underline type:

import zipfile

runs = "".join(
    f'<w:r><w:rPr><w:u w:val="{v}"/></w:rPr><w:t xml:space="preserve">{v} </w:t></w:r>'
    for v in ["single", "double", "thick", "dotted", "dash", "wave", "words", "none"]
)
with zipfile.ZipFile("underline.docx", "w") as z:
    z.writestr(
        "[Content_Types].xml",
        '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">'
        '<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>'
        '<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>'
        "</Types>",
    )
    z.writestr(
        "_rels/.rels",
        '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'
        '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>'
        "</Relationships>",
    )
    z.writestr(
        "word/document.xml",
        '<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">'
        f"<w:body><w:p>{runs}</w:p></w:body></w:document>",
    )
python3 underline.py
pandoc -f docx -t html underline.docx

Actual output

<p><u>single</u> double thick dotted dash wave words none</p>

Expected output

<p><u>single</u> <u>double</u> <u>thick</u> <u>dotted</u> <u>dash</u> <u>wave</u> <u>words</u> none</p>

Version

pandoc 3.12.1 and the 2026-10-23 nightly (66fcaff), Linux x86_64.

Cause

Docx.hs L326-L327 matches only Just "single" <- rUnderline rPr. The rule comes from #1474 (2014), which mapped single underlines to Emph and ignored the other types. The reader now has a real Underline, so a possible fix is to treat every value except none as an underline. The highlight case above it does the same (L308-L310).

Related

Drafted with the help of an AI assistant; every reproduction was run and its output checked.

Activity

  1. patrick-5546 commented on Oct 23, 2026

    @patrick-5546
    ContributorAuthor

    I'll open a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions