ggrossetie / asciidoctor-web-pdf

Convert AsciiDoc documents to PDF using web technologies
https://asciidoctor.org
MIT License
455 stars 92 forks source link

Remove orphaned table headers at page breaks #656

Closed patrickluoyu closed 2 years ago

patrickluoyu commented 2 years ago

When a table spreads across two pages, the header is automatically repeated. However, an orphaned table header could exist on the previous page when the page break occurs exactly after the table header. This PR resolves the above-mentioned problem.

Signed-off-by: Patrick-LuoYu patrickluo@yunify.com

patrickluoyu commented 2 years ago

/assign @Mogztter

ggrossetie commented 2 years ago

Thanks for your contribution! Could you please provide an example where this issue can be reproduced so I can compare before/after?

patrickluoyu commented 2 years ago

For example, assume that we have the following ADOC file:

test.adoc

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

test

[cols='1a,3a']
|===
|test header |test header

|test row 1
|test row 1

|test row 2
|test row 2
|===

And the following CSS file:

test.css

table {
  break-inside: auto;
}

tr {
  break-inside: avoid;
}

If we run asciidoctor-web-pdf test.adoc -a stylesheet="+test.css", this is what happens before:

image

And this is what happens after:

image
ggrossetie commented 2 years ago

Thanks, I will add a test case 👍🏻

ggrossetie commented 2 years ago

I cherry-picked your commit 348cc9fcad30664a2f33f005186aeb15526bbdf2 and added a test case. Thanks!