mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
bump crengine: tables rendering improvements and others
bump crengine, which includes: - Adds support for symbol fonts (local or embedded) - Fix some issues when rendering text in constrained width - Page splitting: fix possible missing blocks - CSS: adds support for 'auto', ignore % for borders - Fix right border drawing position - Fix: adds missing properties in copystyle() - Adds comments, erm_killed rendering method - Adds getRenderedWidths(): get node min/max node content width - Tables rendering: fixes and improvements - getRenderedWidths: enable min_width to be a single CJK char - Fix wrong text wrap avoid in some case - epub.css: add style for 'blockquote' - Fix rendering issue when line ends with an image Adds a few style tweaks related to tables. Enforce table width: 100% in Wikipedia EPUBs to keep previous look, which feels better with the various kinds of tables in Wikipedia pages. Fix unit tests as juliet.epub (full of blockquotes), grew quite a few pages with the epub.css update.
This commit is contained in:
2
base
2
base
Submodule base updated: 1fa2b5715e...03267b1e19
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user