diff options
| author | Matthew Blythe <mblythester+git@gmail.com> | 2024-05-16 13:03:16 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-16 13:03:16 -0600 |
| commit | 1b2f7c7c9f631ab2a7a4b7210987a571e7a09524 (patch) | |
| tree | 44e9210e711c6ab34af2d9a0f45dd4b45ea1394f | |
| parent | f1da34a14442e49747a81a40a40815856c9f894e (diff) | |
resolves #4571 pass cursor to preprocessor when processing first line of AsciiDoc table cell (PR #4572)
| -rw-r--r-- | lib/asciidoctor/table.rb | 2 | ||||
| -rw-r--r-- | test/tables_test.rb | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/asciidoctor/table.rb b/lib/asciidoctor/table.rb index 87ad4c7d..76bfc7fa 100644 --- a/lib/asciidoctor/table.rb +++ b/lib/asciidoctor/table.rb @@ -303,7 +303,7 @@ class Table::Cell < AbstractBlock # QUESTION is is faster to check for :: before splitting? inner_document_lines = cell_text.split LF, -1 if (unprocessed_line1 = inner_document_lines[0]).include? '::' - preprocessed_lines = (PreprocessorReader.new @document, [unprocessed_line1]).readlines + preprocessed_lines = (PreprocessorReader.new @document, [unprocessed_line1], inner_document_cursor).readlines unless unprocessed_line1 == preprocessed_lines[0] && preprocessed_lines.size < 2 inner_document_lines.shift inner_document_lines.unshift(*preprocessed_lines) unless preprocessed_lines.empty? diff --git a/test/tables_test.rb b/test/tables_test.rb index 9b0dd04c..ef878535 100644 --- a/test/tables_test.rb +++ b/test/tables_test.rb @@ -1708,6 +1708,36 @@ context 'Tables' do assert_match(/included content/, output) end + test 'error about unresolved preprocessor directive on first line of an AsciiDoc table cell should have correct cursor' do + begin + tmp_include = Tempfile.new %w(include- .adoc) + tmp_include_dir, tmp_include_path = File.split tmp_include.path + tmp_include.write <<~'EOS' + |=== + |A |B + + |text + a|include::does-not-exist.adoc[] + |=== + EOS + tmp_include.close + input = <<~EOS + first + + include::#{tmp_include_path}[] + + last + EOS + using_memory_logger do |logger| + output = convert_string_to_embedded input, safe: :safe, base_dir: tmp_include_dir + assert_includes output, %(Unresolved directive in #{tmp_include_path}) + assert_message logger, :ERROR, %(#{tmp_include_path}: line 5: include file not found: #{File.join tmp_include_dir, 'does-not-exist.adoc'}), Hash + end + ensure + tmp_include.close! + end + end + test 'cross reference link in an AsciiDoc table cell should resolve to reference in main document' do input = <<~'EOS' == Some |
