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

HTML table parser produces wrong column alignment in some cases. #8119

Open
tarleb opened this issue Jun 12, 2022 · 0 comments
Open

HTML table parser produces wrong column alignment in some cases. #8119

tarleb opened this issue Jun 12, 2022 · 0 comments

Comments

@tarleb
Copy link
Collaborator

tarleb commented Jun 12, 2022

The HTML reader seems to only inspect the first row of the table body when calculating the default alignment of a column. Example:

pandoc -f html -t native
<table>
  <tr><td align="center">center</td></tr>
  <tr><td>default</td></tr>
</table>
^D
[ Table
    ( "" , [] , [] )
    (Caption Nothing [])
    [ ( AlignCenter , ColWidthDefault ) ]
    (TableHead ( "" , [] , [] ) [])
    [ TableBody
        ( "" , [] , [] )
        (RowHeadColumns 0)
        []
        [ Row
            ( "" , [] , [] )
            [ Cell
                ( "" , [] , [] )
                AlignCenter
                (RowSpan 1)
                (ColSpan 1)
                [ Plain [ Str "center" ] ]
            ]
        , Row
            ( "" , [] , [] )
            [ Cell
                ( "" , [] , [] )
                AlignDefault
                (RowSpan 1)
                (ColSpan 1)
                [ Plain [ Str "default" ] ]
            ]
        ]
    ]
    (TableFoot ( "" , [] , [] ) [])
]

The ColSpec should be ( AlignDefault , ColWidthDefault ) instead of ( AlignCenter , ColWidthDefault ); pandoc writers fall back to the column-wide alignment if the cell has AlignDefault alignment.

<table>
<tbody>
<tr class="odd">
<td style="text-align: center;">center</td>
</tr>
<tr class="even">
<td style="text-align: center;">default</td>
</tr>
</tbody>
</table>
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