From 618c5880fa0386e2fdabd3f10ea48ef2db03c311 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Wed, 8 Jun 2022 02:22:19 -0600 Subject: resolves #4297 propagate :to_dir option to document of AsciiDoc table cell (PR #4298) --- CHANGELOG.adoc | 1 + lib/asciidoctor/document.rb | 1 + test/tables_test.rb | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 757102a7..fa846fbf 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -51,6 +51,7 @@ Improvements:: * Target `` element with image more accurately in default stylesheet * Remove form styles from the default stylesheet (#4186) * Set linenums option on source block when line numbering is enabled (#3313) + * Propagate `:to_dir` option to document of AsciiDoc table cell (#4297) Bug Fixes:: diff --git a/lib/asciidoctor/document.rb b/lib/asciidoctor/document.rb index bc6920f0..af5fb51d 100644 --- a/lib/asciidoctor/document.rb +++ b/lib/asciidoctor/document.rb @@ -259,6 +259,7 @@ class Document < AbstractBlock @parent_document = parent_doc options[:base_dir] ||= parent_doc.base_dir options[:catalog_assets] = true if parent_doc.options[:catalog_assets] + options[:to_dir] = parent_doc.options[:to_dir] if parent_doc.options[:to_dir] @catalog = parent_doc.catalog.merge footnotes: [] # QUESTION should we support setting attribute in parent document from nested document? @attribute_overrides = attr_overrides = (parent_doc.instance_variable_get :@attribute_overrides).merge parent_doc.attributes diff --git a/test/tables_test.rb b/test/tables_test.rb index 0e033607..1132d335 100644 --- a/test/tables_test.rb +++ b/test/tables_test.rb @@ -1905,6 +1905,19 @@ context 'Tables' do assert_css 'table > tbody > tr > td:nth-child(2) table > tbody > tr > td', output, 1 end + test 'AsciiDoc table cell should inherit to_dir option from parent document' do + doc = document_from_string <<~'EOS', parse: true, to_dir: testdir + |=== + a| + AsciiDoc table cell + |=== + EOS + + nested_doc = (doc.blocks[0].find_by context: :document, traverse_documents: true)[0] + assert nested_doc.nested? + assert_equal doc.options[:to_dir], nested_doc.options[:to_dir] + end + test 'AsciiDoc table cell should not inherit toc setting from parent document' do input = <<~'EOS' = Document Title -- cgit v1.2.3