From 564db73cd8bfc390708a109d74317b0d2e736f08 Mon Sep 17 00:00:00 2001 From: poire-z Date: Fri, 29 Jan 2021 01:02:07 +0100 Subject: [PATCH] TOC: show en-dash on empty titles --- frontend/apps/reader/modules/readertoc.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/apps/reader/modules/readertoc.lua b/frontend/apps/reader/modules/readertoc.lua index bcdabbc0d..99c21c029 100644 --- a/frontend/apps/reader/modules/readertoc.lua +++ b/frontend/apps/reader/modules/readertoc.lua @@ -42,8 +42,12 @@ function ReaderToc:init() self.ui.menu:registerToMainMenu(self) end -function ReaderToc:cleanUpTocTitle(title) - return (title:gsub("\13", "")) +function ReaderToc:cleanUpTocTitle(title, replace_empty) + title = title:gsub("\13", "") + if replace_empty and title:match("^%s*$") then + title = "\xE2\x80\x93" -- U+2013 En-Dash + end + return title end function ReaderToc:onSetDimensions(dimen) @@ -523,7 +527,7 @@ function ReaderToc:onShowToc() -- build menu items if #self.toc > 0 and not self.toc[1].text then for _,v in ipairs(self.toc) do - v.text = self.toc_indent:rep(v.depth-1)..self:cleanUpTocTitle(v.title) + v.text = self.toc_indent:rep(v.depth-1)..self:cleanUpTocTitle(v.title, true) v.mandatory = v.page if self.ui.document:hasHiddenFlows() then local flow = self.ui.document:getPageFlow(v.page)