lib/asciidoctor/parser.rb in asciidoctor-2.0.21 vs lib/asciidoctor/parser.rb in asciidoctor-2.0.22
- old
+ new
@@ -559,10 +559,11 @@
# returns nil if the line should be dropped
while true
# process lines verbatim
if style && Compliance.strict_verbatim_paragraphs && (VERBATIM_STYLES.include? style)
block_context = style.to_sym
+ cloaked_context = :paragraph
reader.unshift_line this_line
# advance to block parsing =>
break
end
@@ -816,20 +817,21 @@
# either delimited block or styled paragraph
unless block
case block_context
when :listing, :source
- if block_context == :source || (!attributes[1] && (language = attributes[2] || doc_attrs['source-language']))
- if language
+ if block_context == :source || (language = attributes[1] ? nil : attributes[2] || doc_attrs['source-language'])
+ if language # :listing
attributes['style'] = 'source'
attributes['language'] = language
AttributeList.rekey attributes, [nil, nil, 'linenums']
- else
+ else # :source
AttributeList.rekey attributes, [nil, 'language', 'linenums']
if doc_attrs.key? 'source-language'
attributes['language'] = doc_attrs['source-language']
end unless attributes.key? 'language'
+ attributes['cloaked-context'] = cloaked_context unless cloaked_context == :listing
end
if attributes['linenums-option'] || doc_attrs['source-linenums-option']
attributes['linenums'] = ''
end unless attributes.key? 'linenums'
if doc_attrs.key? 'source-indent'
@@ -854,9 +856,10 @@
if language.nil_or_empty?
attributes['language'] = doc_attrs['source-language'] if doc_attrs.key? 'source-language'
else
attributes['language'] = language
end
+ attributes['cloaked-context'] = cloaked_context
if attributes['linenums-option'] || doc_attrs['source-linenums-option']
attributes['linenums'] = ''
end unless attributes.key? 'linenums'
if doc_attrs.key? 'source-indent'
attributes['indent'] = doc_attrs['source-indent']