Top Methods
com.vladsch.flexmark.formatter

public Interface TranslationContext

Known Direct Subinterfaces
com.vladsch.flexmark.formatter.TranslationHandler, com.vladsch.flexmark.formatter.TranslationHandlerFactory, com.vladsch.flexmark.formatter.NodeFormatterContext
Imports
com.vladsch.flexmark.html.renderer.HtmlIdGenerator, com.vladsch.flexmark.util.ast.Node, com.vladsch.flexmark.util.data.MutableDataHolder, org.jetbrains.annotations.NotNull, .Nullable, java.util.function.Function, .Supplier

Method Summary

Modifier and TypeMethod and Description
public void
customPlaceholderFormat(@NotNull TranslationPlaceholderGenerator
placeholder generator
generator
,
@NotNull TranslatingSpanRender
render which will be used with the custom generator
render
)

Temporarily change the format for placeholders

public @Nullable HtmlIdGenerator
public @Nullable MergeContext
public @NotNull RenderPurpose

Returns:

RenderPurpose for current rendering
getRenderPurpose
()

Get the reason this format rendering is being performed

public @NotNull MutableDataHolder
getTranslationStore()

Get MutableDataHolder for storing this translation run values across render purpose phases

public boolean

Returns:

true if non-translating post processor is set
isPostProcessingNonTranslating
()

public boolean

Returns:

true if need to call translation related functions
isTransformingText
()

Returns false if special translation functions are no-ops

During RenderPurpose#TRANSLATION_SPANS this is true During RenderPurpose#TRANSLATED_SPANS this is true During RenderPurpose#TRANSLATED this is true

public void
nonTranslatingSpan(@NotNull TranslatingSpanRender render)

Separate non-translation span.

public void
postProcessNonTranslating(@NotNull Function<String, CharSequence>
id post processor for TRANSLATED purpose
postProcessor
,
@NotNull Runnable
code to which the post processor applies
scope
)

public <T> T
postProcessNonTranslating(@NotNull Function<String, CharSequence>
id post processor for TRANSLATED purpose
postProcessor
,
@NotNull Supplier<T>
code to which the post processor applies
scope
)

public @NotNull CharSequence

Returns:

anchorRef for the phase to be used for rendering
transformAnchorRef
(@NotNull CharSequence
url part without the anchor ref to resolve reference
pageRef
,
@NotNull CharSequence
anchor ref
anchorRef
)

During RenderPurpose#TRANSLATION_SPANS this converts anchorRef to ordinal placeholder id During RenderPurpose#TRANSLATED_SPANS this returns the ordinal placeholder During RenderPurpose#TRANSLATED this returns new anchorRef for the AnchorRefTarget original was referring to

public @NotNull CharSequence

Returns:

text to be used in rendering for this phase
transformNonTranslating
(@Nullable CharSequence
prefix to use on non-translating placeholder so it is interpreted as a proper element during parsing
prefix
,
@NotNull CharSequence
non-rendering text of the node (content will depend on translation phase)
nonTranslatingText
,
@Nullable CharSequence
suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
suffix
,
@Nullable CharSequence
suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
suffix2
)

Transform non-translating text

During RenderPurpose#TRANSLATION_SPANS this converts text to non-translating placeholder based on ordinal id During RenderPurpose#TRANSLATED_SPANS this returns the non-translating placeholder based on ordinal id During RenderPurpose#TRANSLATED this returns the original non-translating text for the nonTranslatingText (placeholder)

public @NotNull CharSequence

Returns:

text to be used in rendering for this phase
transformTranslating
(@Nullable CharSequence
prefix to use on non-translating placeholder so it is interpreted as a proper element during parsing
prefix
,
@NotNull CharSequence
translating but isolated text of the node (content will depend on translation phase)
translatingText
,
@Nullable CharSequence
suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
suffix
,
@Nullable CharSequence
suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing
suffix2
)

Transform translating text but which is contextually isolated from the text block in which it is located ie.

public void
translatingRefTargetSpan(@Nullable Node
target node,
target
,
@NotNull TranslatingSpanRender render)

Separate translation span which is also a ref target

public void
translatingSpan(@NotNull TranslatingSpanRender render)

Separate translation span.

Method Detail

customPlaceholderFormatback to summary
public void customPlaceholderFormat(@NotNull TranslationPlaceholderGenerator generator, @NotNull TranslatingSpanRender render)

Temporarily change the format for placeholders

Parameters
generator:@NotNull TranslationPlaceholderGenerator

placeholder generator

render:@NotNull TranslatingSpanRender

render which will be used with the custom generator

getIdGeneratorback to summary
public @Nullable HtmlIdGenerator getIdGenerator()
Annotations
@Nullable
getMergeContextback to summary
public @Nullable MergeContext getMergeContext()
Annotations
@Nullable
getRenderPurposeback to summary
public @NotNull RenderPurpose getRenderPurpose()

Get the reason this format rendering is being performed

Returns:@NotNull RenderPurpose

RenderPurpose for current rendering

Annotations
@NotNull
getTranslationStoreback to summary
public @NotNull MutableDataHolder getTranslationStore()

Get MutableDataHolder for storing this translation run values across render purpose phases

Annotations
@NotNull
isPostProcessingNonTranslatingback to summary
public boolean isPostProcessingNonTranslating()
Returns:boolean

true if non-translating post processor is set

isTransformingTextback to summary
public boolean isTransformingText()

Returns false if special translation functions are no-ops

During RenderPurpose#TRANSLATION_SPANS this is true During RenderPurpose#TRANSLATED_SPANS this is true During RenderPurpose#TRANSLATED this is true

Returns:boolean

true if need to call translation related functions

nonTranslatingSpanback to summary
public void nonTranslatingSpan(@NotNull TranslatingSpanRender render)

Separate non-translation span. Will generate a paragraph of text which will not be translated

During RenderPurpose#TRANSLATION_SPANS this adds the generated output to translation spans During RenderPurpose#TRANSLATED_SPANS output from renderer is suppressed, instead outputs corresponding translated span During RenderPurpose#TRANSLATED calls render

postProcessNonTranslatingback to summary
public void postProcessNonTranslating(@NotNull Function<String, CharSequence> postProcessor, @NotNull Runnable scope)
Parameters
postProcessor:@NotNull Function<String, CharSequence>

id post processor for TRANSLATED purpose

scope:@NotNull Runnable

code to which the post processor applies

postProcessNonTranslatingback to summary
public <T> T postProcessNonTranslating(@NotNull Function<String, CharSequence> postProcessor, @NotNull Supplier<T> scope)
Parameters
postProcessor:@NotNull Function<String, CharSequence>

id post processor for TRANSLATED purpose

scope:@NotNull Supplier<T>

code to which the post processor applies

Annotations
@NotNull
transformAnchorRefback to summary
public @NotNull CharSequence transformAnchorRef(@NotNull CharSequence pageRef, @NotNull CharSequence anchorRef)

During RenderPurpose#TRANSLATION_SPANS this converts anchorRef to ordinal placeholder id During RenderPurpose#TRANSLATED_SPANS this returns the ordinal placeholder During RenderPurpose#TRANSLATED this returns new anchorRef for the AnchorRefTarget original was referring to

Parameters
pageRef:@NotNull CharSequence

url part without the anchor ref to resolve reference

anchorRef:@NotNull CharSequence

anchor ref

Returns:@NotNull CharSequence

anchorRef for the phase to be used for rendering

Annotations
@NotNull
transformNonTranslatingback to summary
public @NotNull CharSequence transformNonTranslating(@Nullable CharSequence prefix, @NotNull CharSequence nonTranslatingText, @Nullable CharSequence suffix, @Nullable CharSequence suffix2)

Transform non-translating text

During RenderPurpose#TRANSLATION_SPANS this converts text to non-translating placeholder based on ordinal id During RenderPurpose#TRANSLATED_SPANS this returns the non-translating placeholder based on ordinal id During RenderPurpose#TRANSLATED this returns the original non-translating text for the nonTranslatingText (placeholder)

Parameters
prefix:@Nullable CharSequence

prefix to use on non-translating placeholder so it is interpreted as a proper element during parsing

nonTranslatingText:@NotNull CharSequence

non-rendering text of the node (content will depend on translation phase)

suffix:@Nullable CharSequence

suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing

suffix2:@Nullable CharSequence

suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing

Returns:@NotNull CharSequence

text to be used in rendering for this phase

Annotations
@NotNull
transformTranslatingback to summary
public @NotNull CharSequence transformTranslating(@Nullable CharSequence prefix, @NotNull CharSequence translatingText, @Nullable CharSequence suffix, @Nullable CharSequence suffix2)

Transform translating text but which is contextually isolated from the text block in which it is located ie. link reference or image reference

During RenderPurpose#TRANSLATION_SPANS this converts text to non-translating placeholder based on ordinal id and adds it to translation snippets During RenderPurpose#TRANSLATED_SPANS this returns the non-translating placeholder based on ordinal id During RenderPurpose#TRANSLATED this returns the translated text for the translatingText (placeholder)

Parameters
prefix:@Nullable CharSequence

prefix to use on non-translating placeholder so it is interpreted as a proper element during parsing

translatingText:@NotNull CharSequence

translating but isolated text of the node (content will depend on translation phase)

suffix:@Nullable CharSequence

suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing

suffix2:@Nullable CharSequence

suffix to use on non-translating placeholder so it is interpreted as a proper element during parsing

Returns:@NotNull CharSequence

text to be used in rendering for this phase

Annotations
@NotNull
translatingRefTargetSpanback to summary
public void translatingRefTargetSpan(@Nullable Node target, @NotNull TranslatingSpanRender render)

Separate translation span which is also a ref target

Parameters
target:@Nullable Node

target node,

translatingSpanback to summary
public void translatingSpan(@NotNull TranslatingSpanRender render)

Separate translation span. Will generate a paragraph of text which should be translated as one piece

During RenderPurpose#TRANSLATION_SPANS this adds the generated output to translation spans During RenderPurpose#TRANSLATED_SPANS output from renderer is suppressed, instead outputs corresponding translated span During RenderPurpose#TRANSLATED calls render