diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2021-11-11 23:54:14 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2021-11-12 03:23:23 -0700 |
| commit | 611d3f81610a025fa8b448e4dc4ea9dcf0a0e928 (patch) | |
| tree | e3519ba4b3136347c038060d8eabe8d498210cf0 /lib | |
| parent | e51a749f734302e53c3f5042dbc9bf64e27940c8 (diff) | |
simplify processing of author metadata
- return value of process_authors is never empty
- remove authorcount before processing attribute values; remove type check on value
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/asciidoctor/parser.rb | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb index ef00bbf2..325be6fc 100644 --- a/lib/asciidoctor/parser.rb +++ b/lib/asciidoctor/parser.rb @@ -1778,21 +1778,17 @@ class Parser metadata = {} if reader.has_more_lines? && !reader.next_line_empty? - unless (author_metadata = process_authors reader.read_line).empty? - if document - # apply header subs and assign to document - author_metadata.each do |key, val| - # NOTE the attributes substitution only applies for the email record - doc_attrs[key] = ::String === val ? (document.apply_header_subs val) : val unless doc_attrs.key? key - end - - implicit_author = doc_attrs['author'] - implicit_authorinitials = doc_attrs['authorinitials'] - implicit_authors = doc_attrs['authors'] + authorcount = (author_metadata = process_authors reader.read_line).delete 'authorcount' + if document && (doc_attrs['authorcount'] = authorcount) > 0 + author_metadata.each do |key, val| + # apply header subs and assign to document; attributes substitution only relevant for email + doc_attrs[key] = document.apply_header_subs val unless doc_attrs.key? key end - - metadata = author_metadata + implicit_author = doc_attrs['author'] + implicit_authorinitials = doc_attrs['authorinitials'] + implicit_authors = doc_attrs['authors'] end + (metadata = author_metadata)['authorcount'] = authorcount # NOTE this will discard any comment lines, but not skip blank lines process_attribute_entries reader, document |
