Interface MarkflowPlugin
- All Known Implementing Classes:
CorePlugin
Markflow
to configure how parsing and rendering
of Markdown is carried on.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
This class holds registered plugins and used to set dependencies. -
Method Summary
Modifier and TypeMethodDescriptiondefault void
afterRender
(org.commonmark.node.Node document, MarkflowVisitor visitor) This method will be called after rendering (but before applying markdown to a TextView, if such action will happen).default void
afterSetText
(TextView textView) This method will be called after markdown was applied.default void
beforeRender
(org.commonmark.node.Node document) This method will be called before rendering will occur thus making possible topost-process
parsed node (make changes for example).default void
beforeSetText
(TextView textView, Spanned markdown) This method will be called before callingTextView#setText
.default void
configure
(MarkflowPlugin.Registry registry) This method will be called before any other duringMarkflow
instance construction.default void
configureConfig
(MarkflowConfig.Builder builder) Method to configure span factories and miscellaneous used for rendering of Markdown.default void
configureParser
(org.commonmark.parser.Parser.Builder builder) Method to configureParser
(for example register custom extension, etc.).default void
configureTheme
(MarkflowTheme.Builder builder) Method to configureMarkflowTheme
that is used for rendering of Markdown.default void
configureVisitor
(MarkflowVisitor.Builder builder) Method to configure node visitors used for rendering of Markdown.default CharSequence
processMarkdown
(CharSequence markdown) Process input Markdown text and return a CharSequence to be used in parsing stage further.
-
Method Details
-
configure
This method will be called before any other duringMarkflow
instance construction. Used to set dependencies and tweak certain plugin.- Parameters:
registry
- the plugin registry
-
configureParser
Method to configureParser
(for example register custom extension, etc.). -
configureTheme
Method to configureMarkflowTheme
that is used for rendering of Markdown. -
configureConfig
Method to configure span factories and miscellaneous used for rendering of Markdown. -
configureVisitor
Method to configure node visitors used for rendering of Markdown. -
processMarkdown
Process input Markdown text and return a CharSequence to be used in parsing stage further. Can be described aspre-processing
of raw Markdown.The input CharSequence must be read-only by the method implementation. The implementation should return either the input as-is or return a new CharSequence. The implementation should never hold references to the input; and should not hold references the return object, unless the return object is a String (immutable).
This method will be called from ANY thread.
- Parameters:
markdown
- input text to process- Returns:
- processed Markdown text
-
beforeRender
This method will be called before rendering will occur thus making possible topost-process
parsed node (make changes for example).This method will be called from ANY thread.
- Parameters:
document
- the root document
-
afterRender
default void afterRender(@NonNull org.commonmark.node.Node document, @NonNull MarkflowVisitor visitor) This method will be called after rendering (but before applying markdown to a TextView, if such action will happen). It can be used to clean some internal state, or trigger certain action. Please note that modifyingnode
won\'t have any effect as it has been already visited at this stage.This method will be called from ANY thread.
- Parameters:
document
- the root documentvisitor
-MarkflowVisitor
instance used to render Markdown
-
beforeSetText
This method will be called before callingTextView#setText
.It can be useful to prepare a TextView for rendered Markdown.
This method will be called from UI thread.
- Parameters:
textView
- the TextView to whichmarkdown
will be appliedmarkdown
- the rendered Markdown
-
afterSetText
This method will be called after markdown was applied.It can be useful to trigger certain action on spans/textView.
Unlike
beforeSetText(TextView, Spanned)
this method does not receive rendered Markdown as at this point spans must be queried by callingTextView#getText#getSpans
.This method will be called from UI thread.
- Parameters:
textView
- the TextView to which markdown was applied
-