public class DocumentConverter extends Object
Constructor and Description |
---|
DocumentConverter(Options options)
Creates a DocumentConverted with the given options.
|
Modifier and Type | Method and Description |
---|---|
void |
addBlockNode(NodeHandler handler,
String tagnames)
Customize the processing for a node.
|
void |
addInlineNode(NodeHandler handler,
String tagnames)
Customize the processing for a node.
|
String |
addLink(String url,
String recommendedName,
boolean image)
Adds a link to the link set, and returns the actual ID for the link.
|
String |
convert(Document doc)
Convert a document and return a string.
|
void |
convert(Document doc,
OutputStream out)
Convert a document to the given output stream.
|
void |
convert(Document doc,
Writer out)
Convert a document to the given writer.
|
Map<String,NodeHandler> |
getBlockNodes() |
TextCleaner |
getCleaner() |
String |
getInlineContent(NodeHandler currentNode,
Element el)
Recursively processes child nodes and returns the potential output string.
|
String |
getInlineContent(NodeHandler currentNode,
Element el,
boolean undoLeadingEscapes)
Recursively processes child nodes and returns the potential output string.
|
Map<String,NodeHandler> |
getInlineNodes() |
Options |
getOptions() |
BlockWriter |
getOutput() |
void |
setOutput(BlockWriter output) |
void |
walkNodes(NodeHandler currentNode,
Element el)
Loops over the children of an HTML Element, handling TextNode and child Elements.
|
void |
walkNodes(NodeHandler currentNodeHandler,
Element el,
Map<String,NodeHandler> nodeList)
Loops over the children of an HTML Element, handling TextNode and child Elements.
|
public DocumentConverter(Options options)
options
- Options for this converter.public Options getOptions()
public TextCleaner getCleaner()
public Map<String,NodeHandler> getBlockNodes()
public Map<String,NodeHandler> getInlineNodes()
public BlockWriter getOutput()
public void setOutput(BlockWriter output)
public void addInlineNode(NodeHandler handler, String tagnames)
<em>
or <strong>
.
The tagnames is a comma-delimited list of tagnames for
which this handler should be applied.handler
- The handler for the nodestagnames
- One or more tagnamespublic void addBlockNode(NodeHandler handler, String tagnames)
BlockWriter.startBlock()
and
BlockWriter.endBlock()
methods as
appropriate.
The tagnames is a comma-delimited list of tagnames for
which this handler should be applied.handler
- The handler for the nodestagnames
- One or more tagnamespublic void convert(Document doc, Writer out)
Note: It is up to the calling class to handle closing the writer!
doc
- Document to convertout
- Writer to receive the final outputpublic void convert(Document doc, OutputStream out)
Note: It is up to the calling class to handle closing the stream!
doc
- Document to convertout
- OutputStream to receive the final outputpublic String convert(Document doc)
doc
- Document to convertpublic void walkNodes(NodeHandler currentNode, Element el)
currentNode
- The default node handler for TextNodes and IgnoredHTMLElements.el
- The parent HTML Element whose children are being looked at.public void walkNodes(NodeHandler currentNodeHandler, Element el, Map<String,NodeHandler> nodeList)
currentNodeHandler
- The default node handler for TextNodes and IgnoredHTMLElements.el
- The parent HTML Element whose children are being looked at.nodeList
- The list of valid nodes at this level. Should be one of blockNodes or inlineNodespublic String getInlineContent(NodeHandler currentNode, Element el)
currentNode
- The default node handler for TextNodes and IgnoredHTMLElements.el
- The parent HTML Element whose children are being looked at.public String getInlineContent(NodeHandler currentNode, Element el, boolean undoLeadingEscapes)
currentNode
- The default node handler for TextNodes and IgnoredHTMLElements.el
- The parent HTML Element whose children are being looked at.undoLeadingEscapes
- If true, leading escapes are removedpublic String addLink(String url, String recommendedName, boolean image)
url
- URL for linkrecommendedName
- A recommended name for non-simple link IDs. This might be modified.image
- If true, use "img-" instead of "link-" for simple link IDs.Copyright © 2017. All rights reserved.