Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

SeanESCA
Copy link
Contributor

@SeanESCA SeanESCA commented Jul 22, 2025

This PR adds rowspan support to the DocBook reader by reading the morerows attribute in table cells, as mentioned in #10918. Previously, the rowspan was always set to 1 regardless of this attribute. I added a test based on the table in the issue as well.

Besides that, I changed parseTable to read all the rows in thead if there are multiple rows (previously, only the first row was read). It also considers the rows in thead when setting the number of columns. Previously, it only considered those in the body, so it failed to correctly parse tables if there were more cells in a row in the head than the body.

Copy link
Collaborator

@tarleb tarleb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I added some comments, but they are really just comments; none of them needs fixing.

if n > 0 then Just n else Nothing
let numrows = maybe 0 maximum $ nonEmpty
$ map length bodyrows
let numrows = maybe 0 maximum $ nonEmpty
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That trailing space is probably unintentional?

import Data.List.NonEmpty (nonEmpty)
import Data.Maybe (catMaybes,fromMaybe,mapMaybe,maybeToList)
import Data.Text (Text)
import Data.Text (Text, unpack)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many modules that define an unpack function, so most modules in pandoc use the more explicit T.unpack. That's by no means a rule though, importing it this way is fine.

let rowDistance mr = do
case readMaybe $ unpack mr :: Maybe Int of
Just moreRow -> RowSpan $ moreRow + 1
_ -> 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some linting tools will complain about this wildcard use, suggesting to either use a descriptive name like _notAnInt or to be explicit and match on Nothing. This can help to avoid confusion.

Doesn't need fixing, purely FYI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that, but figured it may be better to be consistent with how colspan was handled.

@SeanESCA
Copy link
Contributor Author

Thanks @tarleb! I've removed the trailing space and changed the unpack import.

@tarleb
Copy link
Collaborator

tarleb commented Jul 24, 2025

The test failure is unrelated to these changes, so I'm merging this.

Thanks!

@tarleb tarleb merged commit 937e20d into jgm:main Jul 24, 2025
10 of 14 checks passed
@SeanESCA SeanESCA deleted the docbook-rowspan branch July 25, 2025 07:40
yanntrividic pushed a commit to yanntrividic/pandoc that referenced this pull request Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants