Class EmptyParagraphPostprocessor

java.lang.Object
org.asciidoctor.extension.BaseProcessor
org.asciidoctor.extension.Postprocessor
network.ike.docs.koncept.EmptyParagraphPostprocessor
All Implemented Interfaces:
org.asciidoctor.extension.Processor

public class EmptyParagraphPostprocessor extends org.asciidoctor.extension.Postprocessor
AsciidoctorJ postprocessor that removes empty paragraph blocks from the generated HTML.

IKE topics carry their index terms as standalone indexterm:[...] lines after the section title, separated from the body by a blank line. In the html5 backend index terms produce no visible output, so that blank-line-delimited block renders as an empty <div class="paragraph"><p></p></div>. Sitting between a heading and its first real paragraph, this zero-height block occupies the heading's page-break-after: avoid "keep-with-next" slot in CSS Paged Media (Prince, Antenna House, WeasyPrint): the heading binds to the empty paragraph — which always fits — and the real content breaks to the next page, stranding the heading alone at the page foot.

This processor strips those empty paragraphs so the heading binds to its real first block. It is intentionally scoped to html5: the DocBook→FO and Prawn PDF paths render index terms into a real index (nothing to strip there) and use native keep-with-next on titles, so they neither exhibit the orphan nor should lose their index entries.

Registered per-execution in the asciidoctor-maven-plugin configuration (like KonceptGlossaryProcessor), never via SPI: an SPI-registered Postprocessor crashes the Prawn backend in PostprocessorProxy before any backend guard could run.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new empty-paragraph postprocessor instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    process(org.asciidoctor.ast.Document document, String output)
    Strips empty paragraph blocks from the html5 output; returns other backends' output unchanged.

    Methods inherited from class org.asciidoctor.extension.BaseProcessor

    createBlock, createBlock, createBlock, createBlock, createBlock, createBlock, createBlock, createDocument, createList, createList, createList, createListItem, createListItem, createPhraseNode, createPhraseNode, createPhraseNode, createPhraseNode, createPhraseNode, createPhraseNode, createSection, createSection, createSection, createSection, createSection, createTable, createTable, createTableCell, createTableCell, createTableCell, createTableCell, createTableColumn, createTableColumn, createTableRow, getConfig, log, newCursor, newCursor, newCursor, newReader, newReader, newReader, newReader, parseContent, setConfig, unwrap, updateConfig

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EmptyParagraphPostprocessor

      public EmptyParagraphPostprocessor()
      Creates a new empty-paragraph postprocessor instance.
  • Method Details

    • process

      public String process(org.asciidoctor.ast.Document document, String output)
      Strips empty paragraph blocks from the html5 output; returns other backends' output unchanged.
      Specified by:
      process in class org.asciidoctor.extension.Postprocessor
      Parameters:
      document - the converted document (used only to read the backend)
      output - the rendered document output
      Returns:
      the output with empty paragraph blocks removed (html5 only)