Package com.vladsch.flexmark.formatter
Class Formatter
java.lang.Object
com.vladsch.flexmark.formatter.Formatter
- All Implemented Interfaces:
IRender
Renders a tree of nodes to Markdown.
Start with the builder()
method to configure the renderer. Example:
Formatter formatter = Formatter.builder().build();
formatter.render(node);
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DataKey<EqualizeTrailingMarker>
Deprecated.static final DataKey<EqualizeTrailingMarker>
static final DataKey<BlockQuoteMarker>
static final DataKey<CharSequence>
static final DataKey<CharSequence>
static final Document[]
static final DataKey<CodeFenceMarker>
static final int
Deprecated.static final DataKey<CharWidthProvider>
static final int
Deprecated.static final int
Deprecated.output control for FormattingAppendable, seeLineAppendable.setOptions(int)
static final int
Deprecated.static final DataKey<TableCaptionHandling>
Deprecated.static final DataKey<DiscretionaryText>
Deprecated.Deprecated.static final DataKey<ParserEmulationProfile>
static final DataKey<HeadingStyle>
(package private) final HeaderIdGeneratorFactory
static final NullableDataKey<Pattern>
(package private) final List<LinkResolverFactory>
static final DataKey<ElementAlignment>
static final DataKey<ListBulletMarker>
static final DataKey<ListNumberedMarker>
static final DataKey<ListSpacing>
(package private) final List<NodeFormatterFactory>
private final DataHolder
static final DataKey<ElementPlacement>
static final DataKey<ElementPlacementSort>
Deprecated.static final DataKey<DiscretionaryText>
static final NullableDataKey<String>
static final DataKey<List<TrackedOffset>>
static final DataKey<BasedSequence>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Formatter.Builder
builder()
Create a new builder for configuring anFormatter
.static Formatter.Builder
builder
(DataHolder options) Create a new builder for configuring anFormatter
.private static List<NodeFormatterFactory>
calculateNodeFormatterFactories
(List<NodeFormatterFactory> formatterFactories) @NotNull DataHolder
Get Options for parsinggetTranslationHandler
(TranslationHandlerFactory translationHandlerFactory, HtmlIdGeneratorFactory idGeneratorFactory) getTranslationHandler
(HtmlIdGeneratorFactory idGeneratorFactory) mergeRender
(Document[] documents, int maxTrailingBlankLines) Render the tree of nodes to markdownvoid
mergeRender
(Document[] documents, Appendable output) Render a node to the appendablevoid
mergeRender
(Document[] documents, Appendable output, int maxTrailingBlankLines) mergeRender
(List<Document> documents, int maxTrailingBlankLines) void
mergeRender
(List<Document> documents, Appendable output) void
mergeRender
(List<Document> documents, Appendable output, int maxTrailingBlankLines) Render a node to the appendable@NotNull String
Render the tree of nodes to markdownvoid
render
(@NotNull Node node, @NotNull Appendable output) Render a node to the appendablevoid
render
(@NotNull Node node, @NotNull Appendable output, int maxTrailingBlankLines) Render nodetranslationRender
(Node document, TranslationHandler translationHandler, RenderPurpose renderPurpose) Render the tree of nodes to markdownvoid
translationRender
(Node document, Appendable output, int maxTrailingBlankLines, TranslationHandler translationHandler, RenderPurpose renderPurpose) Render a node to the appendablevoid
translationRender
(Node document, Appendable output, TranslationHandler translationHandler, RenderPurpose renderPurpose) Render a node to the appendable
-
Field Details
-
EMPTY_DOCUMENTS
-
FORMAT_FLAGS
output control for FormattingAppendable, seeLineAppendable.setOptions(int)
-
FORMAT_CONVERT_TABS
Deprecated. -
FORMAT_COLLAPSE_WHITESPACE
Deprecated. -
FORMAT_SUPPRESS_TRAILING_WHITESPACE
Deprecated. -
FORMAT_ALL_OPTIONS
Deprecated. -
GENERATE_HEADER_ID
-
MAX_BLANK_LINES
-
MAX_TRAILING_BLANK_LINES
-
RIGHT_MARGIN
-
APPLY_SPECIAL_LEAD_IN_HANDLERS
-
ESCAPE_SPECIAL_CHARS
-
ESCAPE_NUMBERED_LEAD_IN
-
UNESCAPE_SPECIAL_CHARS
-
SPACE_AFTER_ATX_MARKER
-
SETEXT_HEADING_EQUALIZE_MARKER
-
ATX_HEADING_TRAILING_MARKER
-
HEADING_STYLE
-
THEMATIC_BREAK
-
BLOCK_QUOTE_BLANK_LINES
-
BLOCK_QUOTE_MARKERS
-
INDENTED_CODE_MINIMIZE_INDENT
-
FENCED_CODE_MINIMIZE_INDENT
-
FENCED_CODE_MATCH_CLOSING_MARKER
-
FENCED_CODE_SPACE_BEFORE_INFO
-
FENCED_CODE_MARKER_LENGTH
-
FENCED_CODE_MARKER_TYPE
-
LIST_ADD_BLANK_LINE_BEFORE
-
LIST_RENUMBER_ITEMS
-
LIST_REMOVE_EMPTY_ITEMS
-
LIST_ALIGN_NUMERIC
-
LIST_RESET_FIRST_ITEM_NUMBER
-
LIST_BULLET_MARKER
-
LIST_NUMBERED_MARKER
-
LIST_SPACING
-
LISTS_ITEM_CONTENT_AFTER_SUFFIX
-
REFERENCE_PLACEMENT
-
REFERENCE_SORT
-
KEEP_IMAGE_LINKS_AT_START
-
KEEP_EXPLICIT_LINKS_AT_START
-
OPTIMIZED_INLINE_RENDERING
-
FORMAT_CHAR_WIDTH_PROVIDER
-
KEEP_HARD_LINE_BREAKS
-
KEEP_SOFT_LINE_BREAKS
-
FORMATTER_ON_TAG
-
FORMATTER_OFF_TAG
-
FORMATTER_TAGS_ENABLED
-
FORMATTER_TAGS_ACCEPT_REGEXP
-
LINK_MARKER_COMMENT_PATTERN
-
APPEND_TRANSFERRED_REFERENCES
-
TRANSLATION_ID_FORMAT
-
TRANSLATION_HTML_BLOCK_PREFIX
-
TRANSLATION_HTML_INLINE_PREFIX
-
TRANSLATION_AUTOLINK_PREFIX
-
TRANSLATION_EXCLUDE_PATTERN
-
TRANSLATION_HTML_BLOCK_TAG_PATTERN
-
TRANSLATION_HTML_INLINE_TAG_PATTERN
-
DOC_RELATIVE_URL
-
DOC_ROOT_URL
-
DEFAULT_LINK_RESOLVER
-
FORMATTER_EMULATION_PROFILE
-
TRACKED_OFFSETS
-
TRACKED_SEQUENCE
-
RESTORE_TRACKED_SPACES
-
DOCUMENT_FIRST_PREFIX
-
DOCUMENT_PREFIX
-
SETEXT_HEADER_EQUALIZE_MARKER
Deprecated.use corrected name -
ATX_HEADER_TRAILING_MARKER
Deprecated.use corrected name -
FORMAT_TABLE_CAPTION
Deprecated.use TableFormatOptions instead -
FORMAT_TABLE_CAPTION_SPACES
Deprecated.use TableFormatOptions instead -
FORMAT_TABLE_INDENT_PREFIX
Deprecated.use TableFormatOptions instead -
UNIQUIFICATION_MAP
-
ATTRIBUTE_UNIQUIFICATION_ID_MAP
-
options
-
linkResolverFactories
-
nodeFormatterFactories
-
idGeneratorFactory
-
NULL_ITERATOR
-
NULL_ITERABLE
-
-
Constructor Details
-
Formatter
Formatter(Formatter.Builder builder)
-
-
Method Details
-
calculateNodeFormatterFactories
private static List<NodeFormatterFactory> calculateNodeFormatterFactories(List<NodeFormatterFactory> formatterFactories) -
getTranslationHandler
public TranslationHandler getTranslationHandler(TranslationHandlerFactory translationHandlerFactory, HtmlIdGeneratorFactory idGeneratorFactory) -
getTranslationHandler
-
getTranslationHandler
-
getOptions
Description copied from interface:IRender
Get Options for parsing- Specified by:
getOptions
in interfaceIRender
- Returns:
- DataHolder for options
-
builder
Create a new builder for configuring anFormatter
.- Returns:
- a builder
-
builder
Create a new builder for configuring anFormatter
.- Parameters:
options
- initialization options- Returns:
- a builder.
-
render
Render a node to the appendableNOTE: if Appendable is LineAppendable then its builder will be used as builder for the markdown text, else string sequence builder will be used
-
render
public void render(@NotNull @NotNull Node node, @NotNull @NotNull Appendable output, int maxTrailingBlankLines) Render nodeNOTE: if Appendable is LineAppendable then its builder will be used as builder for the markdown text, else string sequence builder will be used
- Parameters:
node
- node to renderoutput
- appendable to which to render the resulting textmaxTrailingBlankLines
- max trailing blank lines in output, -1 means no last line EOL
-
render
Render the tree of nodes to markdown -
translationRender
public void translationRender(Node document, Appendable output, TranslationHandler translationHandler, RenderPurpose renderPurpose) Render a node to the appendable- Parameters:
document
- node to renderoutput
- appendable to use for the output
-
translationRender
public String translationRender(Node document, TranslationHandler translationHandler, RenderPurpose renderPurpose) Render the tree of nodes to markdown- Parameters:
document
- the root node- Returns:
- the formatted markdown
-
translationRender
public void translationRender(Node document, Appendable output, int maxTrailingBlankLines, TranslationHandler translationHandler, RenderPurpose renderPurpose) Render a node to the appendable- Parameters:
document
- node to renderoutput
- appendable to use for the output
-
mergeRender
Render a node to the appendable- Parameters:
documents
- node to renderoutput
- appendable to use for the output
-
mergeRender
-
mergeRender
Render the tree of nodes to markdown- Parameters:
documents
- the root node- Returns:
- the formatted markdown
-
mergeRender
-
mergeRender
Render a node to the appendable- Parameters:
documents
- nodes to merge renderoutput
- appendable to use for the output
-
mergeRender
-