diff --git a/base b/base index 1fa2b5715..03267b1e1 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 1fa2b5715e2be7432e473940cc623d396aa9f5f7 +Subproject commit 03267b1e195b811abeaf47a4a158d414a0e28d2b diff --git a/frontend/apps/reader/modules/readerhighlight.lua b/frontend/apps/reader/modules/readerhighlight.lua index 10fb3b9fe..c748fc2d2 100644 --- a/frontend/apps/reader/modules/readerhighlight.lua +++ b/frontend/apps/reader/modules/readerhighlight.lua @@ -392,6 +392,7 @@ function ReaderHighlight:viewSelectionHTML(debug_view) -- Each node on a line, with markers and numbers of skipped chars and siblings shown, -- with possibly invalid HTML (text nodes not escaped) html_flags = 0x3353 + -- html_flags = 0x3753 -- use this to additionally see rendering methods end local html, css_files = self.ui.document:getHTMLFromXPointers(self.selected_text.pos0, self.selected_text.pos1, html_flags, true) diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index 597b9e07d..a393dc574 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -191,40 +191,72 @@ h1, h2, h3, h4, h5, h6 { hyphens: none !important; } { title = _("Miscellaneous"), { - id = "table_row_odd_even"; - title = _("Alternate background color of table rows"), - css = [[ + title = _("Tables"), + { + id = "table_full_width"; + title = _("Full-width tables"), + description = _("Make table expand to the full width of the page. (Tables with small content now use only the width needed to display that content. This restores the previous behavior.)"), + css = [[table { width: 100% !important; }]], + }, + { + id = "table_td_width_auto"; + title = _("Ignore publisher table and cell widths"), + description = _("Ignore table and cells widths specified by the publisher, and let the engine decide the most appropriate widths."), + css = [[table, td, th { width: auto !important; }]], + }, + { + id = "table_margin_left_right_auto"; + title = _("Center small tables"), + description = _("Horizontally center tables that do not use the full page width."), + css = [[table { margin-left: auto !important; margin-right: auto !important; }]], + separator = true, + }, + { + id = "td_vertical_align_none"; + title = _("Ignore publisher vertical alignment in tables"), + -- Using "vertical-align: top" would vertical-align children text nodes to top. + -- "vertical-align: baseline" has no meaning in table rendering, and is as fine + css = [[td { vertical-align: baseline !important; }]], + }, + { + id = "table_row_odd_even"; + title = _("Alternate background color of table rows"), + css = [[ tr:nth-child(odd) { background-color: #EEE !important; } tr:nth-child(even) { background-color: #CCC !important; } - ]], - }, - { - id = "table_force_border"; - title = _("Show borders on all tables"), - css = [[ + ]], + }, + { + id = "table_force_border"; + title = _("Show borders on all tables"), + css = [[ table, tcaption, tr, th, td { border: black solid 1px; border-collapse: collapse; } - ]], - separator = true, + ]], + separator = true, + }, }, { - id = "image_full_width"; - title = _("Make images full width"), - description = _("Useful for books containing only images, when they are smaller than your screen. May stretch images in some cases."), - -- This helped me once with a book. Will mess with aspect ratio - -- when images have a style="width: NNpx; heigh: NNpx" - css = [[ + title = _("Images"), + { + id = "image_full_width"; + title = _("Full-width images"), + description = _("Useful for books containing only images, when they are smaller than your screen. May stretch images in some cases."), + -- This helped me once with a book. Will mess with aspect ratio + -- when images have a style="width: NNpx; heigh: NNpx" + css = [[ img { text-align: center !important; text-indent: 0px !important; display: block !important; width: 100% !important; } - ]], - }, - { - id = "image_valign_middle"; - title = _("Vertically center-align images relative to text"), - css = [[img { vertical-align: middle; }]], + ]], + }, + { + id = "image_valign_middle"; + title = _("Vertically center-align images relative to text"), + css = [[img { vertical-align: middle; }]], + }, }, }, -- No current need for workarounds diff --git a/frontend/ui/wikipedia.lua b/frontend/ui/wikipedia.lua index a8d2d6c0a..3965fa661 100644 --- a/frontend/ui/wikipedia.lua +++ b/frontend/ui/wikipedia.lua @@ -992,6 +992,13 @@ li.gallerybox div.gallerytext p { .citation { font-style: italic; } +/* make tables full-width - Wikipedia tables are often set as float + * elements and have a fixed width, often in em (22em), which would + * make them quite small with blank space on their right, as we don't + * support float */ +table { + width: 100% !important; +} /* hide some view/edit/discuss short links displayed as "v m d" */ .nv-view, .nv-edit, .nv-talk { display: none; diff --git a/spec/unit/readerfooter_spec.lua b/spec/unit/readerfooter_spec.lua index 023d6a401..2d28ccc97 100644 --- a/spec/unit/readerfooter_spec.lua +++ b/spec/unit/readerfooter_spec.lua @@ -146,7 +146,7 @@ describe("Readerfooter module", function() local timeinfo = footer.textGeneratorMap.time() local page_count = readerui.document:getPageCount() -- stats has not been initialized here, so we get na TB and TC - assert.are.same('1 / '..page_count..' | '..timeinfo..' | => 0 | B:0% | R:1% | TB: na | TC: na', + assert.are.same('1 / '..page_count..' | '..timeinfo..' | => 1 | B:0% | R:0% | TB: na | TC: na', footer.footer_text.text) end) @@ -295,8 +295,8 @@ describe("Readerfooter module", function() assert.are.same(365, footer.text_width) footer:onPageUpdate(100) - assert.are.same(191, footer.progress_bar.width) - assert.are.same(389, footer.text_width) + assert.are.same(183, footer.progress_bar.width) + assert.are.same(397, footer.text_width) end) it("should support chapter markers", function() @@ -545,7 +545,7 @@ describe("Readerfooter module", function() assert.is.same(0, footer.text_width) tapFooterMenu(fake_menu, "Progress percentage") - assert.are.same('R:1%', footer.footer_text.text) + assert.are.same('R:0%', footer.footer_text.text) assert.is.same(false, footer.has_no_mode) assert.is.same(footer.footer_text:getSize().w + footer.text_left_margin, footer.text_width) diff --git a/spec/unit/readerhighlight_spec.lua b/spec/unit/readerhighlight_spec.lua index 5ae02a34a..941b66de1 100644 --- a/spec/unit/readerhighlight_spec.lua +++ b/spec/unit/readerhighlight_spec.lua @@ -85,22 +85,22 @@ describe("Readerhighlight module", function() readerui.highlight:clear() end) it("should highlight single word", function() - highlight_single_word(readerui, Geom:new{ x = 260, y = 80 }) + highlight_single_word(readerui, Geom:new{ x = 400, y = 110 }) Screen:shot("screenshots/reader_highlight_single_word_epub.png") assert.truthy(readerui.view.highlight.saved[page]) end) it("should highlight text", function() highlight_text(readerui, - Geom:new{ x = 260, y = 60 }, - Geom:new{ x = 260, y = 90 }) + Geom:new{ x = 400, y = 110 }, + Geom:new{ x = 400, y = 170 }) Screen:shot("screenshots/reader_highlight_text_epub.png") assert.truthy(readerui.view.highlight.saved[page]) end) it("should response on tap gesture", function() tap_highlight_text(readerui, - Geom:new{ x = 151, y = 120 }, - Geom:new{ x = 290, y = 301 }, - Geom:new{ x = 200, y = 268 }) + Geom:new{ x = 151, y = 115 }, + Geom:new{ x = 300, y = 285 }, + Geom:new{ x = 120, y = 240 }) Screen:shot("screenshots/reader_tap_highlight_text_epub.png") end) end) diff --git a/spec/unit/readerrolling_spec.lua b/spec/unit/readerrolling_spec.lua index f00ff3acc..d5d270136 100644 --- a/spec/unit/readerrolling_spec.lua +++ b/spec/unit/readerrolling_spec.lua @@ -186,13 +186,13 @@ describe("Readerrolling module", function() it("should show pages for different word gap", function() readerui.document:setSpaceCondensing(100) readerui:handleEvent(Event:new("ChangeScreenMode", "portrait")) - assert.are.same(191, readerui.document:getPageCount()) + assert.are.same(267, readerui.document:getPageCount()) readerui.document:setSpaceCondensing(75) readerui:handleEvent(Event:new("ChangeScreenMode", "portrait")) - assert.are.same(189, readerui.document:getPageCount()) + assert.are.same(262, readerui.document:getPageCount()) readerui.document:setSpaceCondensing(50) readerui:handleEvent(Event:new("ChangeScreenMode", "portrait")) - assert.are.same(189, readerui.document:getPageCount()) + assert.are.same(248, readerui.document:getPageCount()) end) end) diff --git a/spec/unit/readersearch_spec.lua b/spec/unit/readersearch_spec.lua index 6b0b2a442..2029e550e 100644 --- a/spec/unit/readersearch_spec.lua +++ b/spec/unit/readersearch_spec.lua @@ -67,7 +67,7 @@ describe("Readersearch module", function() it("should find the last occurrence", function() -- local logger = require("logger") -- logger.info("nb of pages", doc:getPageCount()) - -- 20180723: currently 189 pages + -- 20181206: currently 267 pages for i = 100, 180, 10 do rolling:onGotoPage(i) local words = search:searchFromEnd("Verona") @@ -76,7 +76,7 @@ describe("Readersearch module", function() -- logger.info("last match on page", pageno) assert.truthy(pageno > 185) end - for i = 230, 235, 1 do + for i = 290, 335, 1 do rolling:onGotoPage(i) local words = search:searchFromEnd("Verona") assert(words == nil) diff --git a/spec/unit/readertoc_spec.lua b/spec/unit/readertoc_spec.lua index 738355e98..b12615640 100644 --- a/spec/unit/readertoc_spec.lua +++ b/spec/unit/readertoc_spec.lua @@ -22,10 +22,10 @@ describe("Readertoc module", function() assert.are.same(2, toc_max_depth) end) it("should get toc title from page", function() - title = toc:getTocTitleByPage(49) + title = toc:getTocTitleByPage(60) DEBUG("toc", toc.toc) assert(title == "SCENE V. A hall in Capulet's house.") - title = toc:getTocTitleByPage(143) + title = toc:getTocTitleByPage(195) assert(title == "SCENE I. Friar Laurence's cell.") end) describe("getTocTicks API", function() @@ -59,7 +59,7 @@ describe("Readertoc module", function() it("should get page of next chapter", function() assert.truthy(toc:getNextChapter(10, 0) > 10) assert.truthy(toc:getNextChapter(100, 0) > 100) - assert.are.same(nil, toc:getNextChapter(200, 0)) + assert.are.same(nil, toc:getNextChapter(290, 0)) end) it("should get page of previous chapter", function() assert.truthy(toc:getPreviousChapter(10, 0) < 10) @@ -68,13 +68,13 @@ describe("Readertoc module", function() end) it("should get page left of chapter", function() assert.truthy(toc:getChapterPagesLeft(10, 0) > 10) - assert.truthy(toc:getChapterPagesLeft(92, 0) > 10) - assert.are.same(nil, toc:getChapterPagesLeft(200, 0)) + assert.truthy(toc:getChapterPagesLeft(102, 0) > 10) + assert.are.same(nil, toc:getChapterPagesLeft(290, 0)) end) it("should get page done of chapter", function() assert.truthy(toc:getChapterPagesDone(12, 0) < 5) assert.truthy(toc:getChapterPagesDone(95, 0) < 5) - assert.truthy(toc:getChapterPagesDone(204, 0) > 10) + assert.truthy(toc:getChapterPagesDone(290, 0) > 10) end) describe("collasible TOC", function() it("should collapse the secondary toc nodes by default", function()