Skip to content

Commit

Permalink
resolves #472 fix crash when section title contains inline anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
slonopotamus committed May 12, 2024
1 parent d3a6427 commit 2339809
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions lib/asciidoctor-epub3/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ def write(output, target)

def initialize(backend, opts = {})
super

@xrefs_seen = Set.new
@media_files = {}
@footnotes = []

basebackend 'html'
outfilesuffix '.epub'
htmlsyntax 'xml'
Expand Down Expand Up @@ -149,9 +154,6 @@ def convert_document(node)
@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
Expand Down
14 changes: 14 additions & 0 deletions spec/converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,20 @@
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'
Expand Down

0 comments on commit 2339809

Please sign in to comment.