Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCX reader to support row head #9495

Closed
rgaiacs opened this issue Feb 22, 2024 · 0 comments
Closed

DOCX reader to support row head #9495

rgaiacs opened this issue Feb 22, 2024 · 0 comments

Comments

@rgaiacs
Copy link
Contributor

rgaiacs commented Feb 22, 2024

Pandoc types has support for row head, see https://pandoc.org/lua-filters.html#type-tablebody, and Microsoft Word allows users to apply "special formatting for the first column", see the "Table Style Options" in the screenshot.

Screenshot 2024-02-22 174809

DOCX reader could treat the selection of "special formatting for the first column" as "the first column is a header".

Minimal Working Examples

table-2x2-single-header.docx

table-2x2-two-headers.docx

XML structure

table-2x2-single-header.docx has

    <w:tbl>
      <w:tblPr>
        <w:tblStyle w:val="GridTable5Dark-Accent1"/>
        <w:tblW w:w="0" w:type="auto"/>
        <w:tblLook w:val="0420" w:firstRow="1" w:lastRow="0" w:firstColumn="0" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/>
      </w:tblPr>

and table-2x2-two-headers.docx has

    <w:tbl>
      <w:tblPr>
        <w:tblStyle w:val="GridTable5Dark-Accent1"/>
        <w:tblW w:w="0" w:type="auto"/>
        <w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/>
      </w:tblPr>

DOCX reader need to check the value of w:firstColumn in <w:tblLook />.

Current Reading

pandoc --from docx --to native table-2x2-two-headers.docx produces

[ Table
    ( "" , [] , [] )
    (Caption Nothing [])
    [ ( AlignDefault , ColWidth 0.5 )
    , ( AlignDefault , ColWidth 0.5 )
    ]
    (TableHead
       ( "" , [] , [] )
       [ Row
           ( "" , [] , [] )
           [ Cell
               ( "" , [] , [] )
               AlignDefault
               (RowSpan 1)
               (ColSpan 1)
               [ Plain [ Str "1" ] ]
           , Cell
               ( "" , [] , [] )
               AlignDefault
               (RowSpan 1)
               (ColSpan 1)
               [ Plain [ Str "2" ] ]
           ]
       ])
    [ TableBody
        ( "" , [] , [] )
        (RowHeadColumns 0)
        []
        [ Row
            ( "" , [] , [] )
            [ Cell
                ( "" , [] , [] )
                AlignDefault
                (RowSpan 1)
                (ColSpan 1)
                [ Plain [ Str "3" ] ]
            , Cell
                ( "" , [] , [] )
                AlignDefault
                (RowSpan 1)
                (ColSpan 1)
                [ Plain [ Str "4" ] ]
            ]
        ]
    ]
    (TableFoot ( "" , [] , [] ) [])
]

Desired Reading

pandoc --from docx --to native table-2x2-two-headers.docx should produce

[ Table
    ( "" , [] , [] )
    (Caption Nothing [])
    [ ( AlignDefault , ColWidth 0.5 )
    , ( AlignDefault , ColWidth 0.5 )
    ]
    (TableHead
       ( "" , [] , [] )
       [ Row
           ( "" , [] , [] )
           [ Cell
               ( "" , [] , [] )
               AlignDefault
               (RowSpan 1)
               (ColSpan 1)
               [ Plain [ Str "1" ] ]
           , Cell
               ( "" , [] , [] )
               AlignDefault
               (RowSpan 1)
               (ColSpan 1)
               [ Plain [ Str "2" ] ]
           ]
       ])
    [ TableBody
        ( "" , [] , [] )
        (RowHeadColumns 1)
        []
        [ Row
            ( "" , [] , [] )
            [ Cell
                ( "" , [] , [] )
                AlignDefault
                (RowSpan 1)
                (ColSpan 1)
                [ Plain [ Str "3" ] ]
            , Cell
                ( "" , [] , [] )
                AlignDefault
                (RowSpan 1)
                (ColSpan 1)
                [ Plain [ Str "4" ] ]
            ]
        ]
    ]
    (TableFoot ( "" , [] , [] ) [])
]

The value of RowHeadColumns is now 1.

Environment

pandoc --version returns

pandoc 3.1.11.1
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/raniere/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant