From 6e28bfb948e34da55b8e8b499534afc23d6d869c Mon Sep 17 00:00:00 2001 From: rupor-github Date: Fri, 29 Jul 2022 18:15:33 -0400 Subject: [PATCH] Fixing notes formating again. This time inline - regression from 1.59.0 --- CMakeLists.txt | 2 +- processor/process.go | 9 ++++++++- processor/xhtml.go | 8 ++------ processor/xmlutils.go | 2 +- static/configuration.toml | 4 ++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02821afc..80b137a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ endif() # Project version number set(PRJ_VERSION_MAJOR 1) set(PRJ_VERSION_MINOR 64) -set(PRJ_VERSION_PATCH 4) +set(PRJ_VERSION_PATCH 5) if (EXISTS "${PROJECT_SOURCE_DIR}/.git" AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git") execute_process(COMMAND ${CMAKE_SOURCE_DIR}/cmake/githash.sh ${GIT_EXECUTABLE} diff --git a/processor/process.go b/processor/process.go index 5cbe8eef..21c4049f 100644 --- a/processor/process.go +++ b/processor/process.go @@ -697,11 +697,18 @@ func (p *Processor) parseNoteSectionElement(el *etree.Element, name string, note bodyName: name, bodyNumber: len(notesPerBody), } + sep := "\n" + if !p.env.Cfg.Doc.Notes.KeepNL { + sep = " " + } for _, c := range el.ChildElements() { if c.Tag == "title" { note.title = SanitizeTitle(getTextFragment(c)) } else { - note.body += getFullTextFragment(c) + if len(note.body) > 0 { + note.body += sep + } + note.body += strings.ReplaceAll(getFullTextFragment(c), "\n", sep) } } p.Book.NotesOrder = append(p.Book.NotesOrder, notelink{id: id, bodyName: name}) diff --git a/processor/xhtml.go b/processor/xhtml.go index 480679c6..7829cf6a 100644 --- a/processor/xhtml.go +++ b/processor/xhtml.go @@ -127,20 +127,16 @@ func (p *Processor) processBody(index int, from *etree.Element) (err error) { } } } - txt := note.body - if !p.env.Cfg.Doc.Notes.KeepNL { - txt = strings.TrimSuffix(strings.ReplaceAll(txt, "\n", " "), " ") - } // NOTE: we are adding .SetTail("\n") to make result readable when debugging, it does not have any other use if p.notesMode == NFloatNew { // new "preffered" HTML5 method with "aside" to.AddNext("aside", attr("id", nl.id), attr("epub:type", "footnote")).SetTail("\n"). AddNext("p", attr("class", "floatnote")). - AddNext("a", attr("href", backRef+"#"+backID)).SetText(t).SetTail(strNBSP + txt) + AddNext("a", attr("href", backRef+"#"+backID)).SetText(t).SetTail(strNBSP + note.body) } else { // old bi-directional mode to.AddNext("p", attr("class", "floatnote"), attr("id", nl.id)).SetTail("\n"). - AddNext("a", attr("href", backRef+"#"+backID)).SetText(t).SetTail(strNBSP + txt) + AddNext("a", attr("href", backRef+"#"+backID)).SetText(t).SetTail(strNBSP + note.body) } } } diff --git a/processor/xmlutils.go b/processor/xmlutils.go index 4c28396d..a2ba1abd 100644 --- a/processor/xmlutils.go +++ b/processor/xmlutils.go @@ -41,7 +41,7 @@ func getTextFragment(e *etree.Element) string { } func getFullTextFragment(e *etree.Element) string { - return extractText(e, false, false) + return extractText(e, true, false) } //lint:ignore U1000 keep getXMLFragment() diff --git a/static/configuration.toml b/static/configuration.toml index 4deecb7b..936a77f3 100644 --- a/static/configuration.toml +++ b/static/configuration.toml @@ -155,8 +155,8 @@ #---- "float-old" - same as "float", pop up notes using "bi-directional links" method #---- "float-new" - pop up notes using "preferred" method - HTML5 with