diff options
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/reader.rb | 6 | ||||
| -rw-r--r-- | test/reader_test.rb | 35 |
3 files changed, 39 insertions, 3 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 121389f6..47acdedd 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -19,6 +19,7 @@ This project utilizes semantic versioning. Bug Fixes:: + * Include all lines outside of specified tagged region when tag filter on include directive is a single negated tag (#4048) * Update default stylesheet to indent blocks attached to list item in checklist (#2550) * Update default stylesheet to reenable styling of implicit lead role on first paragraph of preamble inside AsciiDoc table cell diff --git a/lib/asciidoctor/reader.rb b/lib/asciidoctor/reader.rb index cdc5586c..6512f554 100644 --- a/lib/asciidoctor/reader.rb +++ b/lib/asciidoctor/reader.rb @@ -1140,10 +1140,10 @@ class PreprocessorReader < Reader else select = base_select = wildcard = inc_tags.delete '**' end - elsif inc_tags.key? '*' - select = base_select = !(wildcard = inc_tags.delete '*') + elsif (wildcard = inc_tags.delete '*').nil? + select = base_select = !(inc_tags.value? true) else - select = base_select = false + select = base_select = !wildcard end begin reader.call inc_path, read_mode do |f| diff --git a/test/reader_test.rb b/test/reader_test.rb index b1ac2033..985a3361 100644 --- a/test/reader_test.rb +++ b/test/reader_test.rb @@ -1246,6 +1246,41 @@ class ReaderTest < Minitest::Test assert_includes output, expected end + test 'include directive takes all lines except negated tags when value only contains negated tag' do + input = <<~'EOS' + ---- + include::fixtures/tagged-class.rb[tags=!bark] + ---- + EOS + + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME + # NOTE cannot use single-quoted heredoc because of https://github.com/jruby/jruby/issues/4260 + expected = <<~EOS.chop + class Dog + def initialize breed + @breed = breed + end + end + EOS + assert_includes output, expected + end + + test 'include directive takes all lines except negated tags when value only contains negated tags' do + input = <<~'EOS' + ---- + include::fixtures/tagged-class.rb[tags=!bark;!init] + ---- + EOS + + output = convert_string_to_embedded input, safe: :safe, base_dir: DIRNAME + # NOTE cannot use single-quoted heredoc because of https://github.com/jruby/jruby/issues/4260 + expected = <<~EOS.chop + class Dog + end + EOS + assert_includes output, expected + end + test 'should recognize tag wildcard if not at head of list' do input = <<~'EOS' ---- |
