Package com.vladsch.flexmark.formatter
Class NodeRepositoryFormatter<R extends NodeRepository<B>,B extends Node & ReferenceNode<R,B,N>,N extends Node & ReferencingNode<R,B>>
- java.lang.Object
-
- com.vladsch.flexmark.formatter.NodeRepositoryFormatter<R,B,N>
-
- All Implemented Interfaces:
NodeFormatter
,PhasedNodeFormatter
- Direct Known Subclasses:
AbbreviationNodeFormatter
,CoreNodeFormatter
,EnumeratedReferenceNodeFormatter
,FootnoteNodeFormatter
,MacrosNodeFormatter
public abstract class NodeRepositoryFormatter<R extends NodeRepository<B>,B extends Node & ReferenceNode<R,B,N>,N extends Node & ReferencingNode<R,B>> extends java.lang.Object implements PhasedNodeFormatter
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.HashSet<FormattingPhase>
FORMATTING_PHASES
protected B
lastReference
protected java.util.Comparator<B>
myComparator
protected boolean
recheckUndefinedReferences
protected java.util.List<B>
referenceList
protected R
referenceRepository
protected java.util.Map<java.lang.String,java.lang.String>
referenceUniqificationMap
protected boolean
repositoryNodesDone
protected java.util.HashSet<Node>
unusedReferences
-
Constructor Summary
Constructors Constructor Description NodeRepositoryFormatter(DataHolder options, DataKey<java.util.Map<java.lang.String,java.lang.String>> referenceMapKey, DataKey<java.util.Map<java.lang.String,java.lang.String>> uniquificationMapKey)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.Set<FormattingPhase>
getFormattingPhases()
java.util.Comparator<B>
getReferenceComparator()
abstract ElementPlacement
getReferencePlacement()
abstract ElementPlacementSort
getReferenceSort()
abstract R
getRepository(DataHolder options)
protected ElementPlacement
getTranslationReferencePlacement(NodeFormatterContext context)
protected boolean
makeReferencesUnique()
Whether references should be made uniquejava.lang.String
modifyTransformedReference(java.lang.String transformedReferenceId, NodeFormatterContext context)
void
renderDocument(NodeFormatterContext context, MarkdownWriter markdown, Document document, FormattingPhase phase)
Render the specified node.protected void
renderReference(B node, NodeFormatterContext context, MarkdownWriter markdown)
protected abstract void
renderReferenceBlock(B node, NodeFormatterContext context, MarkdownWriter markdown)
protected java.lang.String
transformReferenceId(java.lang.String nodeText, NodeFormatterContext context)
protected void
uniquifyIds(NodeFormatterContext context, MarkdownWriter markdown, Document document)
Compute needed id map to make reference ids unique across documents[] up to entry equal to document and store this map in document property so that it can be retrieved from the document later when computing the map by documents after this document in the list.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vladsch.flexmark.formatter.NodeFormatter
getBlockQuoteLikePrefixChar, getNodeClasses, getNodeFormattingHandlers
-
-
-
-
Field Detail
-
FORMATTING_PHASES
public static final java.util.HashSet<FormattingPhase> FORMATTING_PHASES
-
referenceRepository
protected final R extends NodeRepository<B> referenceRepository
-
unusedReferences
protected final java.util.HashSet<Node> unusedReferences
-
recheckUndefinedReferences
protected boolean recheckUndefinedReferences
-
repositoryNodesDone
protected boolean repositoryNodesDone
-
myComparator
protected final java.util.Comparator<B extends Node & ReferenceNode<R,B,N>> myComparator
-
referenceUniqificationMap
protected java.util.Map<java.lang.String,java.lang.String> referenceUniqificationMap
-
-
Constructor Detail
-
NodeRepositoryFormatter
public NodeRepositoryFormatter(DataHolder options, DataKey<java.util.Map<java.lang.String,java.lang.String>> referenceMapKey, DataKey<java.util.Map<java.lang.String,java.lang.String>> uniquificationMapKey)
-
-
Method Detail
-
getReferenceComparator
public java.util.Comparator<B> getReferenceComparator()
-
getRepository
public abstract R getRepository(DataHolder options)
-
getReferencePlacement
public abstract ElementPlacement getReferencePlacement()
-
getReferenceSort
public abstract ElementPlacementSort getReferenceSort()
-
renderReferenceBlock
protected abstract void renderReferenceBlock(B node, NodeFormatterContext context, MarkdownWriter markdown)
-
makeReferencesUnique
protected boolean makeReferencesUnique()
Whether references should be made unique- Returns:
- true if yes, false if leave all references as is
-
getTranslationReferencePlacement
protected ElementPlacement getTranslationReferencePlacement(NodeFormatterContext context)
-
modifyTransformedReference
public java.lang.String modifyTransformedReference(java.lang.String transformedReferenceId, NodeFormatterContext context)
-
transformReferenceId
protected java.lang.String transformReferenceId(java.lang.String nodeText, NodeFormatterContext context)
-
getFormattingPhases
@Nullable public java.util.Set<FormattingPhase> getFormattingPhases()
- Specified by:
getFormattingPhases
in interfacePhasedNodeFormatter
-
renderDocument
public void renderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase)
Description copied from interface:PhasedNodeFormatter
Render the specified node.- Specified by:
renderDocument
in interfacePhasedNodeFormatter
- Parameters:
context
- node renderer context instancemarkdown
- markdown writer instancedocument
- the document node to renderphase
- rendering phase for which to generate the output. Will be any ofFormattingPhase
exceptFormattingPhase.DOCUMENT
because this phase is used for the non-phased node rendering
-
renderReference
protected void renderReference(B node, NodeFormatterContext context, MarkdownWriter markdown)
-
uniquifyIds
protected void uniquifyIds(NodeFormatterContext context, MarkdownWriter markdown, Document document)
Compute needed id map to make reference ids unique across documents[] up to entry equal to document and store this map in document property so that it can be retrieved from the document later when computing the map by documents after this document in the list.- Parameters:
context
-markdown
-document
-
-
-