public class Processor
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,java.lang.Object> |
config |
static java.lang.String |
CONTENT_MODEL
This value is used as the config option key to configure how Asciidoctor should treat blocks created by
this Processor.
|
static java.lang.String |
CONTENT_MODEL_ATTRIBUTES
Predefined constant to make Asciidoctor parse content as attributes.
|
static java.lang.String |
CONTENT_MODEL_COMPOUND
Predefined constant to let Asciidoctor know that this BlockProcessor creates zero or more child blocks.
|
static java.lang.String |
CONTENT_MODEL_EMPTY
Predefined constant to make Asciidoctor not expect any content.
|
static java.lang.String |
CONTENT_MODEL_RAW
Predefined constant to make Asciidoctor pass through the content unprocessed.
|
static java.lang.String |
CONTENT_MODEL_SIMPLE
Predefined constant to let Asciidoctor know that this BlockProcessor creates simple paragraph content.
|
static java.lang.String |
CONTENT_MODEL_SKIP
Predefined constant to make Asciidoctor drop the content.
|
static java.lang.String |
CONTENT_MODEL_VERBATIM
Predefined constant to let Asciidoctor know that this BlockProcessor creates literal content.
|
| Constructor and Description |
|---|
Processor() |
Processor(java.util.Map<java.lang.String,java.lang.Object> config) |
| Modifier and Type | Method and Description |
|---|---|
Block |
createBlock(StructuralNode parent,
java.lang.String context,
java.util.List<java.lang.String> content) |
Block |
createBlock(StructuralNode parent,
java.lang.String context,
java.util.List<java.lang.String> content,
java.util.Map<java.lang.String,java.lang.Object> attributes) |
Block |
createBlock(StructuralNode parent,
java.lang.String context,
java.util.List<java.lang.String> content,
java.util.Map<java.lang.String,java.lang.Object> attributes,
java.util.Map<java.lang.Object,java.lang.Object> options) |
Block |
createBlock(StructuralNode parent,
java.lang.String context,
java.lang.String content) |
Block |
createBlock(StructuralNode parent,
java.lang.String context,
java.lang.String content,
java.util.Map<java.lang.String,java.lang.Object> attributes) |
Block |
createBlock(StructuralNode parent,
java.lang.String context,
java.lang.String content,
java.util.Map<java.lang.String,java.lang.Object> attributes,
java.util.Map<java.lang.Object,java.lang.Object> options) |
Document |
createDocument(Document parentDocument)
Creates an inner document for the given parent document.
|
PhraseNode |
createPhraseNode(ContentNode parent,
java.lang.String context,
java.util.List<java.lang.String> text) |
PhraseNode |
createPhraseNode(ContentNode parent,
java.lang.String context,
java.util.List<java.lang.String> text,
java.util.Map<java.lang.String,java.lang.Object> attributes) |
PhraseNode |
createPhraseNode(ContentNode parent,
java.lang.String context,
java.util.List<java.lang.String> text,
java.util.Map<java.lang.String,java.lang.Object> attributes,
java.util.Map<java.lang.Object,java.lang.Object> options) |
PhraseNode |
createPhraseNode(ContentNode parent,
java.lang.String context,
java.lang.String text) |
PhraseNode |
createPhraseNode(ContentNode parent,
java.lang.String context,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.Object> attributes) |
PhraseNode |
createPhraseNode(ContentNode parent,
java.lang.String context,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.Object> attributes,
java.util.Map<java.lang.String,java.lang.Object> options) |
Section |
createSection(StructuralNode parent) |
Section |
createSection(StructuralNode parent,
boolean numbered,
java.util.Map<java.lang.Object,java.lang.Object> options) |
Section |
createSection(StructuralNode parent,
int level,
boolean numbered,
java.util.Map<java.lang.Object,java.lang.Object> options) |
Section |
createSection(StructuralNode parent,
java.util.Map<java.lang.Object,java.lang.Object> options) |
Table |
createTable(StructuralNode parent) |
Table |
createTable(StructuralNode parent,
java.util.Map<java.lang.String,java.lang.Object> attributes) |
Cell |
createTableCell(Column column,
Document innerDocument) |
Cell |
createTableCell(Column column,
Document innerDocument,
java.util.Map<java.lang.String,java.lang.Object> attributes) |
Cell |
createTableCell(Column column,
java.lang.String text) |
Cell |
createTableCell(Column column,
java.lang.String text,
java.util.Map<java.lang.String,java.lang.Object> attributes) |
Column |
createTableColumn(Table parent,
int index) |
Column |
createTableColumn(Table parent,
int index,
java.util.Map<java.lang.String,java.lang.Object> attributes) |
Row |
createTableRow(Table parent) |
java.util.Map<java.lang.String,java.lang.Object> |
getConfig() |
void |
parseContent(StructuralNode parent,
java.util.List<java.lang.String> lines)
Parses the given raw asciidoctor content, parses it and appends it as children to the given parent block.
|
void |
setConfig(java.util.Map<java.lang.String,java.lang.Object> config) |
void |
setConfigFinalized()
Lock the config of this processor so that it is no longer allowed to invoke
setConfig(Map). |
public static final java.lang.String CONTENT_MODEL
Example to Asciidoctor know that a BlockProcessor creates zero or more child blocks:
Map<String, Object> config = new HashMap<>(); config.put(CONTENT_MODEL, CONTENT_MODEL_COMPOUND); BlockProcessor blockProcessor = new BlockProcessor("foo", config); asciidoctor.javaExtensionRegistry().block(blockProcessor);
public static final java.lang.String CONTENT_MODEL_COMPOUND
public static final java.lang.String CONTENT_MODEL_SIMPLE
public static final java.lang.String CONTENT_MODEL_VERBATIM
public static final java.lang.String CONTENT_MODEL_RAW
public static final java.lang.String CONTENT_MODEL_SKIP
public static final java.lang.String CONTENT_MODEL_EMPTY
public static final java.lang.String CONTENT_MODEL_ATTRIBUTES
protected java.util.Map<java.lang.String,java.lang.Object> config
public Processor()
public Processor(java.util.Map<java.lang.String,java.lang.Object> config)
public java.util.Map<java.lang.String,java.lang.Object> getConfig()
public final void setConfig(java.util.Map<java.lang.String,java.lang.Object> config)
public final void setConfigFinalized()
setConfig(Map).public Table createTable(StructuralNode parent)
public Table createTable(StructuralNode parent, java.util.Map<java.lang.String,java.lang.Object> attributes)
public Column createTableColumn(Table parent, int index, java.util.Map<java.lang.String,java.lang.Object> attributes)
public Cell createTableCell(Column column, Document innerDocument, java.util.Map<java.lang.String,java.lang.Object> attributes)
public Cell createTableCell(Column column, java.lang.String text, java.util.Map<java.lang.String,java.lang.Object> attributes)
public Block createBlock(StructuralNode parent, java.lang.String context, java.lang.String content)
public Block createBlock(StructuralNode parent, java.lang.String context, java.lang.String content, java.util.Map<java.lang.String,java.lang.Object> attributes)
public Block createBlock(StructuralNode parent, java.lang.String context, java.lang.String content, java.util.Map<java.lang.String,java.lang.Object> attributes, java.util.Map<java.lang.Object,java.lang.Object> options)
public Block createBlock(StructuralNode parent, java.lang.String context, java.util.List<java.lang.String> content)
public Block createBlock(StructuralNode parent, java.lang.String context, java.util.List<java.lang.String> content, java.util.Map<java.lang.String,java.lang.Object> attributes)
public Block createBlock(StructuralNode parent, java.lang.String context, java.util.List<java.lang.String> content, java.util.Map<java.lang.String,java.lang.Object> attributes, java.util.Map<java.lang.Object,java.lang.Object> options)
public Section createSection(StructuralNode parent)
public Section createSection(StructuralNode parent, java.util.Map<java.lang.Object,java.lang.Object> options)
public Section createSection(StructuralNode parent, boolean numbered, java.util.Map<java.lang.Object,java.lang.Object> options)
public Section createSection(StructuralNode parent, int level, boolean numbered, java.util.Map<java.lang.Object,java.lang.Object> options)
public PhraseNode createPhraseNode(ContentNode parent, java.lang.String context, java.util.List<java.lang.String> text)
public PhraseNode createPhraseNode(ContentNode parent, java.lang.String context, java.util.List<java.lang.String> text, java.util.Map<java.lang.String,java.lang.Object> attributes)
public PhraseNode createPhraseNode(ContentNode parent, java.lang.String context, java.util.List<java.lang.String> text, java.util.Map<java.lang.String,java.lang.Object> attributes, java.util.Map<java.lang.Object,java.lang.Object> options)
public PhraseNode createPhraseNode(ContentNode parent, java.lang.String context, java.lang.String text)
public PhraseNode createPhraseNode(ContentNode parent, java.lang.String context, java.lang.String text, java.util.Map<java.lang.String,java.lang.Object> attributes)
public PhraseNode createPhraseNode(ContentNode parent, java.lang.String context, java.lang.String text, java.util.Map<java.lang.String,java.lang.Object> attributes, java.util.Map<java.lang.String,java.lang.Object> options)
public Document createDocument(Document parentDocument)
asciidoc.parentDocument - The parent document of the new document.public void parseContent(StructuralNode parent, java.util.List<java.lang.String> lines)
The following example will add two paragraphs with the role newcontent to all top
level sections of a document:
Asciidoctor asciidoctor = ...
asciidoctor.javaExtensionRegistry().treeprocessor(new Treeprocessor() {
DocumentRuby process(DocumentRuby document) {
for (AbstractBlock block: document.getBlocks()) {
if (block instanceof Section) {
parseContent(block, Arrays.asList(new String[]{
"[newcontent]",
"This is new content"
"",
"[newcontent]",
"This is also new content"}));
}
}
}
});
parent - The block to which the parsed content should be added as children.lines - Raw asciidoctor content