Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: an option to split the XHTML files at a lower heading level #327

Closed
programandala-net opened this issue Apr 13, 2020 · 22 comments

Comments

@programandala-net
Copy link

I'm finishing the manual of a software project of mine. The Asciidoctor source is built automatically by combining several documents of the project, including parts of the README, with a lot of information extracted from the source code, and marking the cross references during the process. Then the resulting Asciidoctor document is converted into EPUB, PDF and other formats.

The result is great, except one problem with the EPUB format: one of the chapters is a huge glossary (with subchapters for the initials), which becomes a 2-MiB XHTML file in the EPUB. This makes the document too slow to open and navigate.

I suggest an option to force the splitting of the contents into XHTML files at a certain heading level, equivalent to Pandoc's --epub-chapter-level.

slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Apr 16, 2020
@slonopotamus slonopotamus added this to the v1.5.0.alpha.16 milestone Apr 16, 2020
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Apr 16, 2020
@slonopotamus
Copy link
Contributor

@programandala-net Great suggestion! I've just implemented this in #328. Would you like to review or test it before it gets merged into master?

@programandala-net
Copy link
Author

programandala-net commented Apr 16, 2020 via email

@slonopotamus
Copy link
Contributor

Aaaaand... It's in the master!

@programandala-net
Copy link
Author

programandala-net commented Apr 17, 2020 via email

@slonopotamus
Copy link
Contributor

Could you provide a minimal asciidoctor file that reproduces the problem please?

@slonopotamus slonopotamus reopened this Apr 17, 2020
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Apr 18, 2020
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Apr 18, 2020
slonopotamus added a commit to slonopotamus/asciidoctor-epub3 that referenced this issue Apr 18, 2020
@slonopotamus
Copy link
Contributor

I found (and fixed) a bug in TOC when epub-chapter-level is > 1, but from what you said I guess you have a different issue.

@slonopotamus slonopotamus reopened this Apr 18, 2020
@programandala-net
Copy link
Author

programandala-net commented Apr 18, 2020 via email

@slonopotamus
Copy link
Contributor

the subchapters of my glossary twice: in its chapter and outside, as independent chapters

Yeah, that's exactly what I fixed.

@slonopotamus
Copy link
Contributor

@programandala-net ping?

@programandala-net
Copy link
Author

programandala-net commented Apr 23, 2020 via email

@programandala-net
Copy link
Author

I have found the reason the XHTML splitting didn't work in my test files: :doctype: book was missing. Is this intended? I think I have read somewhere that "book" was always assumed in the EPUB conversion.

@slonopotamus
Copy link
Contributor

Currently, yes:

When doctype attribute is set to book, each top-level section will become a separate ebook "chapter" file. This includes preface, bibliography, appendix, etc.

Otherwise, whole document is converted to a single ebook chapter.

So, currently epub-chapter-level changes at what level chapter splitting should happen (and it cannot be < 1) while doctype determines whether splitting is done at all.

Default doctype is article. Articles do not normally have chapters, don't they?

Technically, we could change the logic between doctype/epub-chapter-level and say that article defaults to epub-chapter-level=0 while book defaults to epub-chapter-level=1.

@programandala-net
Copy link
Author

I see. I was confused. The current behaviour makes sense.

It seems epub-chapter-level=0 is currently ignored? The result is identical to epub-chapter-level=1, and no warning is displayed.

@programandala-net
Copy link
Author

Here you are the test files, with epub-chapter-level values 1..3. Links pointing outside their final XHTML file don't work. This didn't happen before this attribute was implemented: links worked between chapters. Beside, when epub-chapter-level=3, something else fails (Calibre displays error messages, and fbreader displays blank pages).
cross_references_with_epub-chapter-level_test_files.zip

@slonopotamus
Copy link
Contributor

slonopotamus commented Apr 25, 2020

Hmm... You're using inline anchors inside section titles. Is it valid at all?

Sections are normally given anchors via syntax like:

[#anchor]
== Section title

or

[[anchor]]
== Section title

@programandala-net
Copy link
Author

Yes, it's valid according to the examples included in the manual, and it always worked before as I said.

@programandala-net
Copy link
Author

I've moved the anchors outside the titles. Now the links work, but the subchapters are repeated in the TOC displayed by Calibre, except when epub-chapter-level=1. Please find the modified versions attached.

There's another difference: no warning about missing target ids is displayed anymore. This is a problem that already happened before epub-chapter-level was implemented. Therefore the warnings are caused by the inline anchor syntax, even if it works.
cross_references_with_epub-chapter-level_and_anchors_outside_titles_test_files.zip

@slonopotamus
Copy link
Contributor

slonopotamus commented Apr 26, 2020

There's another difference: no warning about missing target ids is displayed anymore. This is a problem that already happened before epub-chapter-level was implemented. Therefore the warnings are caused by the inline anchor syntax, even if it works.

I'll split this into a separate issue. We are not currently able to properly handle inline anchors in section titles, that's why you see a warning. Unfortunately, it needs some fixes to asciidoctor core, so in nearest future just try to avoid inline anchors in section titles.

UPDATE: #331

@slonopotamus
Copy link
Contributor

I've moved the anchors outside the titles. Now the links work, but the subchapters are repeated in the TOC displayed by Calibre, except when epub-chapter-level=1. Please find the modified versions attached.

I think you're using asciidoctor-epub without commit 861afde. I do not observe duplicate TOC entries on your test documents if using latest master branch.

@programandala-net
Copy link
Author

I'll split this into a separate issue. We are not currently able to properly handle inline anchors in section titles, that's why you see a warning. Unfortunately, it needs some fixes to asciidoctor core, so in nearest future just try to avoid inline anchors in section titles.

UPDATE: #331

OK. I used the inline syntax because I needed two different anchors per glossary entry, in order to manage the homonyms. Example:

=== a

[#entry61-src-lib-assembler-fs]
==== [[entry61]]a
(...)

[#entry61-src-lib-memory-address_register-fs]
==== a
(...)

I will think an alternative.

@programandala-net
Copy link
Author

I think you're using asciidoctor-epub without commit 861afde. I do not observe duplicate TOC entries on your test documents if using latest master branch.

You're right. Sorry. My local repository was updated indeed, but somehow something went wrong in my latest building and I didn't noticed. Now the TOCs are right.

@slonopotamus
Copy link
Contributor

alpha-16 was just released, with this feature included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants