Enhancement: return links for footnotes when converting from odt

Bug #1421056 reported by J March on 2015-02-12
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Undecided
Unassigned

Bug Description

Currently, converting from odt just gives an ordered list of footnotes. This is fine for kindle devices with a back button, but is not so fun on the kindle app (I'm on android). So, I propose tweaking these functions in odf2xhtml.py to this:

    def generate_footnotes(self):
        if self.currentnote == 0:
            return
        for key in range(1,self.currentnote+1):
            note = self.notedict[key]
            self.opentag('a',{ 'href': "#anchor-%d" % key, 'id': "footnote-%d" % key })
            self.writeout("[%d]" % key)
            self.closetag('a')
            self.writeout(note['body'])

and

    def e_text_note_citation(self, tag, attrs):
        self.opentag('a',{ 'href': "#footnote-%s" % self.currentnote, 'id': "anchor-%s" % self.currentnote })
        self.opentag('sup')
        # Since HTML only knows about endnotes, there is too much risk that the
        # marker is reused in the source. Therefore we force numeric markers
        if sys.version_info.major==3:
            self.writeout(self.currentnote)
        else:
            self.writeout(unicode(self.currentnote))
        self.closetag('sup')
        self.closetag('a')

Thank you,
Joshua

I'll look at this when I have some time (since the odfpy library is
abandonware, I tend to approach making changes to it with some
trepidation). In the meantime, you could just save your ODT files as
DOCX, calibre has its own DOCX engine that supports many more features
than odfpy, including this one (docx footnotes and endnotes are
auto-converted to nicely formattted endnotes with big backlinks, well
suited for use with a touchscreen).

J March (lg-ub5ntu-w3) wrote :

Thank you for your quick response. I wouldn't be opposed to using docx but when I tried to have OpenOffice export my file, it created several other formatting issues, like turning my headings to bulleted or numbered lists, or losing page breaks. I'm not sure how I could approach it differently; I use named styles for all my formatting -- not manual or direct styles. So, I gain the nice footnote back links, but then have to wrestle with other formatting issues. The odt files (and I've converted nearly 100) have done well, except for the few cases where I've had footnotes. I know this is a relatively small thing, but I think the simple changes I suggested above would take care of it. It does look like odfpy (https://github.com/eea/odfpy) isn't completely abandoned. There has been some activity over the past year (mainly merging in pull requests). Perhaps it is still an option?

Thank you again,
Joshua

Fixed in branch master. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers