summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarat Radchenko <marat@slonopotamus.org>2024-05-12 15:38:59 +0300
committerMarat Radchenko <marat@slonopotamus.org>2024-05-12 15:38:59 +0300
commit233980903a8a661b0f154e2480ed6cf605bc3a65 (patch)
tree536fe852139628224d85456a4ef214bf97f30478
parentd3a642763aa8501bfd53ce4713d7b44b7c92020e (diff)
resolves #472 fix crash when section title contains inline anchor
-rw-r--r--CHANGELOG.adoc4
-rw-r--r--lib/asciidoctor-epub3/converter.rb8
-rw-r--r--spec/converter_spec.rb14
3 files changed, 23 insertions, 3 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index d349173..822a584 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -5,6 +5,10 @@
This document provides a high-level view of the changes to the {project-name} by release.
For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
+== Unreleased
+
+* fix crash when section title contains inline anchor (#472)
+
== 2.1.0 (2024-02-04) - @slonopotamus
* drop MOBI support
diff --git a/lib/asciidoctor-epub3/converter.rb b/lib/asciidoctor-epub3/converter.rb
index 0492daf..652e7f0 100644
--- a/lib/asciidoctor-epub3/converter.rb
+++ b/lib/asciidoctor-epub3/converter.rb
@@ -95,6 +95,11 @@ module Asciidoctor
def initialize(backend, opts = {})
super
+
+ @xrefs_seen = Set.new
+ @media_files = {}
+ @footnotes = []
+
basebackend 'html'
outfilesuffix '.epub'
htmlsyntax 'xml'
@@ -149,9 +154,6 @@ module Asciidoctor
@extract = node.attr? 'ebook-extract'
@compress = node.attr 'ebook-compress'
@epubcheck_path = node.attr 'ebook-epubcheck-path'
- @xrefs_seen = ::Set.new
- @media_files = {}
- @footnotes = []
@book = GEPUB::Book.new 'EPUB/package.opf'
@book.epub_backward_compat = true
diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb
index a400384..47394b1 100644
--- a/spec/converter_spec.rb
+++ b/spec/converter_spec.rb
@@ -277,6 +277,20 @@ describe Asciidoctor::Epub3::Converter do
expect(book).not_to be_nil
end
+ # Test for https://github.com/asciidoctor/asciidoctor-epub3/issues/472
+ it 'does not crash when sees inline anchor' do
+ book = to_epub <<~EOS
+ = Test
+ :doctype: book
+
+ [[chapter-1]]
+ == Chapter 1
+
+ == <<chapter-1>> Chapter 2
+ EOS
+ expect(book).not_to be_nil
+ end
+
it 'supports video' do
book, = to_epub fixture_file('video/book.adoc')
chapter = book.item_by_href '_chapter.xhtml'