Skip to content

Commit

Permalink
Ruby: keep any last text wrapped in internal table elements
Browse files Browse the repository at this point in the history
Some publishers include 〘 and 〙 around a <rt> so that,
when ruby is not supported, these are displayed inline and
wrap the annotation.
We'd rather have them not shown by having them wrapped and
swallowed/hidden among table-like elements.
  • Loading branch information
poire-z committed Jun 5, 2022
1 parent 9a79160 commit e30435c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions crengine/src/lvtinydom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extern const int gDOMVersionCurrent = DOM_VERSION_CURRENT;

/// change in case of incompatible changes in swap/cache file format to avoid using incompatible swap file
// increment to force complete reload/reparsing of old file
#define CACHE_FILE_FORMAT_VERSION "3.05.68k"
#define CACHE_FILE_FORMAT_VERSION "3.05.69k"
/// increment following value to force re-formatting of old book after load
#define FORMATTING_VERSION_ID 0x002D

Expand Down Expand Up @@ -7236,7 +7236,13 @@ void ldomNode::initNodeRendMethod()
// We'll also not start a wrap with it.
}
}
if ( last_to_wrap >= 0 && (eoc || (elemId != el_rt && elemId != el_rtc && elemId != el_rp && elemId != -2) ) ) {
// A non-empty text node (elemId==-1) would trigger a wrap of what's before. If it happens
// to be the last child, keep it included in the last wrap to not have some dangling text
// (some publishers include 〘 and 〙 around a <rt> so that, when ruby is not supported,
// these are displayed inline and wrap the annotation; we'd rather have them not shown by
// having them wrapped and swallowed/hidden among table-like elements).
if ( last_to_wrap >= 0 && (eoc || (elemId != el_rt && elemId != el_rtc && elemId != el_rp &&
elemId != -2 && !(elemId==-1 && i==len-1)) ) ) {
if ( false && getDocument()->hasCacheFile() ) { // (20200626: this is no longer an issue)
// (We can only move/add nodes while we don't yet have a cache file)
getDocument()->setBoxingWishedButPreventedByCache();
Expand Down Expand Up @@ -7269,6 +7275,9 @@ void ldomNode::initNodeRendMethod()
if ( first_to_wrap < 0 ) {
first_to_wrap = i;
}
if ( i == len-1) { // last child: include it in the wrap (see above)
last_to_wrap = i;
}
}
else if ( elemId == -2 ) { // isText(), empty
// Don't start a wrap on it
Expand Down

0 comments on commit e30435c

Please sign in to comment.