wshito / asciidoctor-chunker

The utility to create chunked HTML files from the single HTML generated by Asciidoctor.
MIT License
25 stars 7 forks source link

Preserve Section Title in Chunked Pages #30

Open tajmone opened 2 years ago

tajmone commented 2 years ago

Currently every chunked page has the same <title>. It would be nice is each page (beside the Title Page) could instead show its Section title in <title>; i.e. by extracting it from the first <h2> tag encountered in each chunked page.

This would allow readers to always see the in the browser title of the sections they are currently viewing (useful in documents with very long chapters), as well as in other types of publications (exeBooks, etc.) where there's a title bar showing the <title> contents of the current page being navigated.

Additionally, a command line switch could allow to define a prefix to be added in <title>, before the extracted section title, so that users can insert the book title (or a brief version of it). E.g. using the option --title-suffix="Git Book:" would produce titles like "Git Book: Introduction", "Git Book: 1. Installing Git", etc., in the chunked pages.

This would also improve the visibility of a publication on search engines, since the <title> tag is parsed for keywords and has a high impact in terms of ranking.

wshito commented 2 years ago

This should be done in your asciidoc source files. You can easily achieve it with setting attributes conditionally. Asciidoctor-chunker is a tool to split single html, not a tool to modify the document contents.

tajmone commented 2 years ago

This should be done in your asciidoc source files. You can easily achieve it with setting attributes conditionally. Asciidoctor-chunker is a tool to split single html, not a tool to modify the document contents.

I don't think this is possible to achieve from AsciiDoc sources: it's the chunker that decides what goes into the <title> tag of each split HTML document.

At the most, in the AsciiDoc source I could control which title to show in the <title> tag of the generated HTML doc (i.e. using the HTML5 backend specific attribute), but the chunker would still apply the same title to each split HTML file.

wshito commented 2 years ago

Oh, excuse me. I thought you wanted to change the every single section title. Yes, I agree with you that there must be other users to prefer different styles. I reopen this issue. But I will most probably try to achieve this with themes.