From 2b1053c05d8f6e5e07d4cbcec27a430d48e6ea22 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 21 Nov 2013 09:15:41 +0530 Subject: [PATCH] Prevent splitting inside tables --- src/calibre/ebooks/oeb/polish/preview.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/polish/preview.coffee b/src/calibre/ebooks/oeb/polish/preview.coffee index e596e1c6bd..f4da783e3c 100644 --- a/src/calibre/ebooks/oeb/polish/preview.coffee +++ b/src/calibre/ebooks/oeb/polish/preview.coffee @@ -27,6 +27,13 @@ is_block = (elem) -> style = window.getComputedStyle(elem) return style.display in ['block', 'flex-box', 'box'] +in_table = (elem) -> + while elem + if elem.tagName?.toLowerCase() == 'table' + return true + elem = elem.parentNode + return false + find_containing_block = (elem) -> while elem and elem.getAttribute('data-is-block') != '1' elem = elem.parentNode @@ -69,7 +76,7 @@ class PreviewIntegration if this.blocks_found return for elem in document.body.getElementsByTagName('*') - if is_block(elem) + if is_block(elem) and not in_table(elem) elem.setAttribute('data-is-block', '1') this.blocks_found = true