summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2021-10-22 17:50:51 -0600
committerGitHub <noreply@github.com>2021-10-22 17:50:51 -0600
commitff247f8009b81baf4a5c26667c19587e499cb66c (patch)
tree417fd828b0de420325356ca9750b1aa977924ffb /lib
parentfbf1c236940edc9fa5e610afd8d5d1157dde14ca (diff)
resolve #4192 honor :header_only option when parsing document with manpage doctype (PR #4193)
Diffstat (limited to 'lib')
-rw-r--r--lib/asciidoctor/parser.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb
index 628b79dc..2cb5bc5b 100644
--- a/lib/asciidoctor/parser.rb
+++ b/lib/asciidoctor/parser.rb
@@ -90,10 +90,10 @@ class Parser
#
# returns the Document object
def self.parse reader, document, options = {}
- block_attributes = parse_document_header reader, document
+ block_attributes = parse_document_header reader, document, (header_only = options[:header_only])
# NOTE don't use a postfix conditional here as it's known to confuse JRuby in certain circumstances
- unless options[:header_only]
+ unless header_only
while reader.has_more_lines?
new_section, block_attributes = next_section reader, document, block_attributes
if new_section
@@ -118,7 +118,7 @@ class Parser
# which are automatically removed by the reader.
#
# returns the Hash of orphan block attributes captured above the header
- def self.parse_document_header reader, document
+ def self.parse_document_header reader, document, header_only = false
# capture lines of block-level metadata and plow away comment lines that precede first block
block_attrs = reader.skip_blank_lines ? (parse_block_metadata_lines reader, document) : {}
doc_attrs = document.attributes
@@ -183,7 +183,7 @@ class Parser
end
# parse title and consume name section of manpage document
- parse_manpage_header reader, document, block_attrs if document.doctype == 'manpage'
+ parse_manpage_header reader, document, block_attrs, header_only if document.doctype == 'manpage'
# NOTE block_attrs are the block-level attributes (not document attributes) that
# precede the first line of content (document title, first section or first block)
@@ -193,7 +193,7 @@ class Parser
# Public: Parses the manpage header of the AsciiDoc source read from the Reader
#
# returns Nothing
- def self.parse_manpage_header reader, document, block_attributes
+ def self.parse_manpage_header reader, document, block_attributes, header_only = false
if ManpageTitleVolnumRx =~ (doc_attrs = document.attributes)['doctitle']
doc_attrs['manvolnum'] = manvolnum = $2
doc_attrs['mantitle'] = (((mantitle = $1).include? ATTR_REF_HEAD) ? (document.sub_attributes mantitle) : mantitle).downcase
@@ -210,6 +210,8 @@ class Parser
doc_attrs['docname'] = manname
doc_attrs['outfilesuffix'] = %(.#{manvolnum})
end
+ elsif header_only
+ # done
else
reader.skip_blank_lines
reader.save