The reason is that reader is shared by our gem and the original Asciidoctor::Document. In the gem if we first use parser to read all headers, the original Document no longer parses them because the reader's Cursor has already advanced past the header.
Therefore we use a newly created trio of the Document, Reader and Parser to achieve this parsing here.
Previously other header attributes (title, toc, etc) will be missing due to this code:
The reason is that
reader
is shared by our gem and the originalAsciidoctor::Document
. In the gem if we first use parser to read all headers, the originalDocument
no longer parses them because thereader
's Cursor has already advanced past the header.Therefore we use a newly created trio of the
Document
,Reader
andParser
to achieve this parsing here.