Class ToMarkdownContentHandler

java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.apache.tika.sax.ToMarkdownContentHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class ToMarkdownContentHandler extends DefaultHandler
SAX event handler that writes content as Markdown. Supports headings, paragraphs, bold, italic, strikethrough, links, images, lists (ordered and unordered, including nested), tables (GFM pipe tables), code blocks, inline code, blockquotes, horizontal rules, and definition lists.

The handler builds a commonmark-java document model from the SAX event stream and renders it with commonmark's MarkdownRenderer. Document text is added to the model as raw literals, so escaping of Markdown metacharacters — including characters that would otherwise break out of a link, image, or table cell — is performed in one place by the renderer rather than at each emit site.

The handler tolerates malformed input (unbalanced or misnested tags): block elements are always attached at a structurally valid point so a well-formed document model is rendered regardless of the event stream.

Content within <script> and <style> tags is ignored.

Since:
Apache Tika 3.2