summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarat Radchenko <marat@slonopotamus.org>2024-05-12 16:16:47 +0300
committerGitHub <noreply@github.com>2024-05-12 16:16:47 +0300
commit9d2cfc2561034f4ce2ec4fabdaadbe2c4489e9c2 (patch)
tree9af88b8812d9951b5da86dc84d85ccf30a2dc705 /lib
parent59bd1302a3d478347e203aa74e3dbb9c050d8c5d (diff)
resolves #470 do not crash on an SVG image inside table cell (#473)
closes #471
Diffstat (limited to 'lib')
-rw-r--r--lib/asciidoctor-epub3/converter.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/asciidoctor-epub3/converter.rb b/lib/asciidoctor-epub3/converter.rb
index 652e7f0..257d3b0 100644
--- a/lib/asciidoctor-epub3/converter.rb
+++ b/lib/asciidoctor-epub3/converter.rb
@@ -76,6 +76,10 @@ module Asciidoctor
EPUB_EXTENSION_RX = /\.epub$/i.freeze
+ # This is a workaround for https://github.com/asciidoctor/asciidoctor/issues/4380
+ # Currently, there is no access to parent cell from inner document
+ PARENT_CELL_FIELD_NAME = :@epub3_parent_cell
+
QUOTE_TAGS = begin
tags = {
monospaced: ['<code>', '</code>', true],
@@ -796,6 +800,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
else
case cell.style
when :asciidoc
+ cell.inner_document.instance_variable_set(PARENT_CELL_FIELD_NAME, cell)
cell_content = %(<div class="embed">#{cell.content}</div>)
when :verse
cell_content = %(<div class="verse">#{cell.text}</div>)
@@ -1156,7 +1161,11 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
return nil if node.nil?
return node unless get_chapter_filename(node).nil?
- node = node.parent
+ node = if node.instance_variable_defined?(PARENT_CELL_FIELD_NAME)
+ node.instance_variable_get(PARENT_CELL_FIELD_NAME)
+ else
+ node.parent
+ end
end
end