NLdoc.Conversion.Reader.Docx.PostProcess (NLdoc.Conversion.Reader.Docx v1.1.2)
View SourceThis module performs post-processing on the intermediate result of a Docx conversion
to an NLdoc spec document with NLdoc.Conversion.Reader.Docx.Convert
.
This post-processing essentially does the following:
- Recursively reverse the order of the children of every spec object in the document.
This is done because
NLdoc.Conversion.Reader.Docx.Convert
accumulates all resources in reverse order, as Elixir implements lists as linked lists and prepending to such a list is O(1), while appending to a linked list is O(n). - If the Docx document had a Title element, increment the level of every heading in the document by 1.
Title elements are converted to a
Heading
with level 0, so in order to result in a valid NLdoc document, if a document had a title heading, all headings must be incremented by 1.
Summary
Types
@type conversion() :: {[NLdoc.Spec.object()], NLdoc.Conversion.Reader.Docx.State.t()}
Functions
@spec process(NLdoc.Spec.Document.t(), NLdoc.Conversion.Reader.Docx.State.t()) :: NLdoc.Spec.Document.t()
@spec process(NLdoc.Spec.object() | [NLdoc.Spec.object()], conversion()) :: conversion()
@spec process( NLdoc.Spec.Document.t(), NLdoc.Conversion.Reader.Docx.State.t(), NLdoc.Conversion.Reader.Docx.t() ) :: NLdoc.Spec.Document.t()