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_PHASESprotected BlastReferenceprotected java.util.Comparator<B>myComparatorprivate DataKey<java.util.Map<java.lang.String,java.lang.String>>myReferenceMapKeyprivate DataKey<java.util.Map<java.lang.String,java.lang.String>>myReferenceUniqificationMapKeyprotected booleanrecheckUndefinedReferencesprotected java.util.List<B>referenceListprotected RreferenceRepositoryprivate java.util.Map<java.lang.String,java.lang.String>referenceTranslationMapprotected java.util.Map<java.lang.String,java.lang.String>referenceUniqificationMapprotected booleanrepositoryNodesDoneprotected 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 private voidformatReferences(NodeFormatterContext context, MarkdownWriter markdown)@Nullable java.util.Set<FormattingPhase>getFormattingPhases()java.util.Comparator<B>getReferenceComparator()abstract ElementPlacementgetReferencePlacement()abstract ElementPlacementSortgetReferenceSort()abstract RgetRepository(DataHolder options)protected ElementPlacementgetTranslationReferencePlacement(NodeFormatterContext context)protected booleanmakeReferencesUnique()Whether references should be made uniquejava.lang.StringmodifyTransformedReference(java.lang.String transformedReferenceId, NodeFormatterContext context)voidrenderDocument(@NotNull NodeFormatterContext context, @NotNull MarkdownWriter markdown, @NotNull Document document, @NotNull FormattingPhase phase)Render the specified node.protected voidrenderReference(B node, NodeFormatterContext context, MarkdownWriter markdown)protected abstract voidrenderReferenceBlock(B node, NodeFormatterContext context, MarkdownWriter markdown)private voidrenderReferenceBlockUnique(B node, NodeFormatterContext context, MarkdownWriter markdown)protected java.lang.StringtransformReferenceId(java.lang.String nodeText, NodeFormatterContext context)protected voiduniquifyIds(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
-
referenceTranslationMap
private java.util.Map<java.lang.String,java.lang.String> referenceTranslationMap
-
referenceUniqificationMap
protected java.util.Map<java.lang.String,java.lang.String> referenceUniqificationMap
-
myReferenceMapKey
private final DataKey<java.util.Map<java.lang.String,java.lang.String>> myReferenceMapKey
-
myReferenceUniqificationMapKey
private final DataKey<java.util.Map<java.lang.String,java.lang.String>> myReferenceUniqificationMapKey
-
-
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)
-
renderReferenceBlockUnique
private void renderReferenceBlockUnique(B node, NodeFormatterContext context, MarkdownWriter markdown)
-
transformReferenceId
protected java.lang.String transformReferenceId(java.lang.String nodeText, NodeFormatterContext context)
-
getFormattingPhases
@Nullable public @Nullable java.util.Set<FormattingPhase> getFormattingPhases()
- Specified by:
getFormattingPhasesin interfacePhasedNodeFormatter
-
renderDocument
public void renderDocument(@NotNull @NotNull NodeFormatterContext context, @NotNull @NotNull MarkdownWriter markdown, @NotNull @NotNull Document document, @NotNull @NotNull FormattingPhase phase)Description copied from interface:PhasedNodeFormatterRender the specified node.- Specified by:
renderDocumentin 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 ofFormattingPhaseexceptFormattingPhase.DOCUMENTbecause this phase is used for the non-phased node rendering
-
formatReferences
private void formatReferences(NodeFormatterContext context, MarkdownWriter markdown)
-
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-
-
-