diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2019-03-20 04:36:24 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2019-03-20 23:20:29 -0600 |
| commit | 507a74aa70a2cd58d89ff037d68af4a2484ce456 (patch) | |
| tree | d03f5b7d80023ff2f4b6b9e4da18172e8fd04cdb | |
| parent | 09a93951f0b09e2f01b1234a31f24e041c36609f (diff) | |
simplify drop-line detection when substituting attributes in target of include directive
| -rw-r--r-- | lib/asciidoctor/reader.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/asciidoctor/reader.rb b/lib/asciidoctor/reader.rb index 260ac11e..3fa8e0bb 100644 --- a/lib/asciidoctor/reader.rb +++ b/lib/asciidoctor/reader.rb @@ -1014,9 +1014,8 @@ class PreprocessorReader < Reader def preprocess_include_directive target, attrlist doc = @document if ((expanded_target = target).include? ATTR_REF_HEAD) && - (precursor_target = doc.sub_attributes target + ' ', attribute_missing: ((attr_missing = doc.attributes['attribute-missing'] || Compliance.attribute_missing) == 'warn' ? 'drop-line' : attr_missing)) && - (expanded_target = precursor_target.chop).empty? - if attr_missing == 'drop-line' && precursor_target.empty? + (expanded_target = doc.sub_attributes target, attribute_missing: ((attr_missing = doc.attributes['attribute-missing'] || Compliance.attribute_missing) == 'warn' ? 'drop-line' : attr_missing)).empty? + if attr_missing == 'drop-line' && (doc.sub_attributes target + ' ', drop_line_severity: :ignore).empty? logger.info message_with_context %(include dropped due to missing attribute: include::#{target}[#{attrlist}]), source_location: cursor if logger.info? shift true @@ -1024,7 +1023,7 @@ class PreprocessorReader < Reader shift true else - logger.warn message_with_context %(include skipped #{attr_missing == 'warn' && precursor_target.empty? ? 'due to missing attribute' : 'because resolved target is blank'}: include::#{target}[#{attrlist}]), source_location: cursor + logger.warn message_with_context %(include skipped #{attr_missing == 'warn' && (doc.sub_attributes target + ' ', attribute_missing: 'drop-line', drop_line_severity: :ignore).empty? ? 'due to missing attribute' : 'because resolved target is blank'}: include::#{target}[#{attrlist}]), source_location: cursor replace_next_line %(Unresolved directive in #{@path} - include::#{target}[#{attrlist}]) end elsif include_processors? && (ext = @include_processor_extensions.find {|candidate| candidate.instance.handles? expanded_target }) |
