diff options
| author | Marat Radchenko <marat@slonopotamus.org> | 2020-07-01 14:39:30 +0300 |
|---|---|---|
| committer | Marat Radchenko <marat@slonopotamus.org> | 2020-07-01 14:39:30 +0300 |
| commit | 552171c3b6d035fa97231ef7a65a5eaefd6ed573 (patch) | |
| tree | 3386fe5219d763c73ffad58dca1891fa547bea8c /lib | |
| parent | 4f25291e6978676d6967c6f74c923570d16a3343 (diff) | |
resolves #343 fix chapter titles to actually be chapter titles instead of document title
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/asciidoctor-epub3/converter.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/asciidoctor-epub3/converter.rb b/lib/asciidoctor-epub3/converter.rb index 3ff5a09..c067f76 100644 --- a/lib/asciidoctor-epub3/converter.rb +++ b/lib/asciidoctor-epub3/converter.rb @@ -301,20 +301,22 @@ module Asciidoctor chapter_item = @book.add_ordered_item %(#{docid}.xhtml) - if node.context == :document && (doctitle = node.doctitle partition: true, use_fallback: true).subtitle? + doctitle = node.document.doctitle partition: true, use_fallback: true + doctitle_sanitized = sanitize_xml doctitle.combined, :cdata + + if node.context == :document && doctitle.subtitle? title = %(#{doctitle.main} ) subtitle = doctitle.subtitle elsif node.title # HACK: until we get proper handling of title-only in CSS title = '' subtitle = get_numbered_title node + doctitle_sanitized = sanitize_xml subtitle, :cdata else title = nil subtitle = nil end - doctitle_sanitized = (node.document.doctitle sanitize: true, use_fallback: true).to_s - # By default, Kindle does not allow the line height to be adjusted. # But if you float the elements, then the line height disappears and can be restored manually using margins. # See https://github.com/asciidoctor/asciidoctor-epub3/issues/123 @@ -382,7 +384,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) { lines << %(</head> <body> -<section class="chapter" title="#{doctitle_sanitized.gsub '"', '"'}" epub:type="chapter" id="#{docid}"> +<section class="chapter" title="#{doctitle_sanitized}" epub:type="chapter" id="#{docid}"> #{header} #{content}) |
