Fix ePUB table markup

This commit is contained in:
Tetrakern 2023-01-27 11:32:41 +01:00
parent ab8209c5e3
commit 7fa390b9e3
3 changed files with 20 additions and 11 deletions

View File

@ -328,7 +328,7 @@ ol ol {
width: auto;
margin: 0 auto;
}
.wp-block-table thead, .wp-block-table tbody, .wp-block-table tfoot, .wp-block-table tr, .wp-block-table td, .wp-block-table th {
.wp-block-table thead, .wp-block-table tbody, .wp-block-table tr, .wp-block-table td, .wp-block-table th {
border-width: inherit;
border-style: solid;
border-color: inherit;
@ -341,7 +341,7 @@ ol ol {
.wp-block-table th, .wp-block-table td {
padding: 6px 9px;
}
.wp-block-table tfoot td {
.wp-block-table .tr-footer td {
font-size: 87.5%;
font-weight: 700;
vertical-align: top;
@ -357,8 +357,8 @@ ol ol {
z-index: 1;
padding: 8px 12px;
}
.wp-block-table.is-style-stripes tbody tr:nth-child(odd) th::before,
.wp-block-table.is-style-stripes tbody tr:nth-child(odd) td::before {
.wp-block-table.is-style-stripes tbody tr:not(.tr-footer):nth-child(odd) th::before,
.wp-block-table.is-style-stripes tbody tr:not(.tr-footer):nth-child(odd) td::before {
content: "";
pointer-events: none;
position: absolute;
@ -371,8 +371,8 @@ ol ol {
background: currentColor;
opacity: 0.04;
}
.wp-block-table.is-style-stripes tfoot td {
padding: 6px 16px;
.wp-block-table.is-style-stripes .tr-footer td {
padding: 6px 12px;
}
.wp-block-separator {

View File

@ -406,6 +406,13 @@ if ( ! function_exists( 'fictioneer_add_epub_chapters' ) ) {
$node->parentNode->removeChild( $node );
}
// Add tr-footer class to <tr> children of tfoot
foreach ( $doc->getElementsByTagName( 'tfoot' ) as $node ) {
foreach ( $node->childNodes as $child_node ) {
$child_node->setAttribute( 'class', 'tr-footer' );
}
}
// Copy images displayed in chapter to ePUB directory and remember them for later
foreach ( $finder->query( "//*[contains(@class, 'wp-block-image')]" ) as $node ) {
// Extract image from wrapper(s)
@ -487,6 +494,8 @@ if ( ! function_exists( 'fictioneer_add_epub_chapters' ) ) {
$file_content = str_replace( '</u>', '</span>', $file_content );
$file_content = str_replace( '<s>', '<span class="strike">', $file_content );
$file_content = str_replace( '</s>', '</span>', $file_content );
$file_content = str_replace( '<tfoot>', '<tbody>', $file_content );
$file_content = str_replace( '</tfoot>', '</tbody>', $file_content );
// Fix invalid entities (because of course)
$file_content = fictioneer_fix_html_entities( $file_content );

View File

@ -403,7 +403,7 @@ ol {
margin: 0 auto;
}
thead, tbody, tfoot, tr, td, th {
thead, tbody, tr, td, th {
border-width: inherit;
border-style: solid;
border-color: inherit;
@ -419,7 +419,7 @@ ol {
padding: 6px 9px;
}
tfoot {
.tr-footer {
td {
font-size: 87.5%;
font-weight: 700;
@ -445,7 +445,7 @@ ol {
}
tbody {
tr {
tr:not(.tr-footer) {
&:nth-child(odd) {
th::before,
td::before {
@ -465,9 +465,9 @@ ol {
}
}
tfoot {
.tr-footer {
td {
padding: 6px 16px;
padding: 6px 12px;
}
}
}