Bug 114164 - EPUB Export: Headings Levels other than Heading 1 are omitted in Outline
Summary: EPUB Export: Headings Levels other than Heading 1 are omitted in Outline
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.0.0.0.alpha0+
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 133442 138617 (view as bug list)
Depends on:
Blocks: EPUB-Export
  Show dependency treegraph
 
Reported: 2017-11-30 09:26 UTC by Kevin Suo
Modified: 2022-11-29 17:50 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Suo 2017-11-30 09:26:00 UTC
Steps to Reproduce:
1. Type in two paragraphs with Heading 1 and Heading 2 styles.
2. Export as EPUB.
3. Open the EPUB file in your epub reader which supports outline.

Current Behaviour:
Only Heading 1 is shown in the epub reader outline.

Expected:
All the outline styles such as H1, H2... are correctly exported to the epub file so that the epub reader can show them as outline.

Version: 6.0.0.0.beta1
Build ID:97471ab4eb4db4c487195658631696bb3238656c
CPU 线程:4; 操作系统:Linux 4.13; UI 渲染:默认; VCL: gtk2; 
Locale: zh-CN (zh_CN.UTF-8); Calc: group threaded
Comment 1 Dieter 2017-11-30 20:16:08 UTC
I conform it. I used a document with for different levels of headings. Only the Heading 1 was shown in the outline. When I create a PDF-Document (as a tagged PDF), all headings appear in the outline.

Version: 6.0.0.0.beta1 (x64)
Build ID: 97471ab4eb4db4c487195658631696bb3238656c
CPU threads: 4; OS: Windows 10.0; UI render: default; 
Locale: de-DE (de_DE); Calc: group threaded
Comment 2 Miklos Vajna 2017-12-01 08:59:05 UTC
Can you provide a sample EPUB that has this feature? Our current table-of-contents lists the XHTML files inside the EPUB, and we split the XHTML files on heading 1 paragraphs.

So listing heading2, etc. in the table-of-contents would either require some kind of link not only to the XHTML file, but also a bookmark inside that file, or would mean more split (even on heading 2, etc), which is also unwanted.

So the first step here would be to find out what EPUB markup is desired to have this.
Comment 3 Kevin Suo 2017-12-01 09:53:35 UTC
These are very good epub3 samples: http://idpf.github.io/epub3-samples/30/samples.html

Among these, the 2nd one, "Children's Literature", seems to have a multi-level TOC. The source codes for this epub can be found at:
https://github.com/IDPF/epub3-samples/tree/master/30/childrens-literature/EPUB

I did a brief analysis of the toc.ncx, and find that the implementation is simple: (i.e., navPoint inside navPoint)
<navPoint id="np-319">
	<navLabel>
		<text>190 A FOUR-LEAVED CLOVER</text>
	</navLabel>
	<content src="s04.xhtml#pgepubid00503"/>
	<navPoint id="d1e54">
		<navLabel>
			<text> I. The Rabbi and the Diadem </text>
		</navLabel>
		<content src="s04.xhtml#pgepubid99001"/>
	</navPoint>
	<navPoint id="d1e60">
		<navLabel>
			<text> II. Friendship </text>
		</navLabel>
		<content src="s04.xhtml#pgepubid99002"/>
	</navPoint>
	<navPoint id="d1e66">
		<navLabel>
			<text> III. True Charity </text>
		</navLabel>
		<content src="s04.xhtml#pgepubid99003"/>
	</navPoint>
	<navPoint id="d1e72">
		<navLabel>
			<text> IV. An Eastern Garden </text>
		</navLabel>
		<content src="s04.xhtml#pgepubid99004"/>
	</navPoint>
</navPoint>

Also, you do not need to separate the sub-sections. Set a "name=pgepubid99001" in the target heading and use sth like src="s04.xhtml#pgepubid99001" in the TOC.
Comment 4 Kevin Suo 2017-12-01 09:59:25 UTC
And here is a link which describes "Transforming NCX into EPUB 3 Navigation Documents":
https://www.safaribooksonline.com/blog/2011/06/14/ncx-into-epub3/
Comment 5 Dieter 2017-12-01 10:46:38 UTC
(In reply to Miklos Vajna from comment #2)
> Can you provide a sample EPUB that has this feature?

I bought some EPUBs with this feature, but of course I can't add them here because of the copyright.
Comment 6 Miklos Vajna 2017-12-04 13:57:19 UTC
OK, the markup seems to be relatively clear. Problem is that we have no anchors for headings, so the ToC can't refer to them. One could try to find out how normal in-document ToC manages to have a reference to headings, and then do something similar as part of the EPUB export.

And yes, EPUB2 has ncx, EPUB3 has a html5-based ToC document, but sounds like both nicely allow nesting.
Comment 7 Michael Bauer 2018-11-01 23:32:09 UTC
I can confirm this bug is still around in 6.1.2.1. Which is a shame because LO otherwise produces nice and clean epubs off doc/odt files. I tried calibre on the doc I was trying to convert and while it did TOC levels 2 and 3 correctly, it messed up the graphics in the process.
Is there perhaps something in the calibre code that could inform a way of fixing this in LO?
Comment 8 lbartolome 2018-11-16 19:52:22 UTC
(In reply to Miklos Vajna from comment #2)
> Can you provide a sample EPUB that has this feature? Our current
> table-of-contents lists the XHTML files inside the EPUB, and we split the
> XHTML files on heading 1 paragraphs.
> 
> So listing heading2, etc. in the table-of-contents would either require some
> kind of link not only to the XHTML file, but also a bookmark inside that
> file, or would mean more split (even on heading 2, etc), which is also
> unwanted.
> 
> So the first step here would be to find out what EPUB markup is desired to
> have this.

Miklos, this might be a useful way to handle it, they included an id for the desired headers instead of adding bookmarks. With the extension you can also select if you want page breaks at header levels different than 1 or not.
<!-- This file was converted to xhtml by Writer2xhtml ver. 1.6.1. See http://writer2latex.sourceforge.net for more info. --><head>
    <title></title>
    <link href="../Styles/styles1.css" rel="stylesheet" type="text/css"/>
  </head>
  <body dir="ltr">
    <h1 id="toc0">Ñsjdna</h1>
    <p class="Textbody">&#160;</p>
    <p class="Textbody">&#160;</p>
    <h2 id="toc1">i&lt;ksjdas</h2>
    <p class="Textbody">&#160;</p>
    <h3 id="toc2">i&lt;sjdasd</h3>
    <p class="Textbody">&#160;</p>
Comment 9 Dieter 2020-06-08 05:21:19 UTC
*** Bug 133442 has been marked as a duplicate of this bug. ***
Comment 10 Roman Kuznetsov 2020-12-02 18:55:54 UTC
*** Bug 138617 has been marked as a duplicate of this bug. ***