Interface MarkflowPlugin

All Known Implementing Classes:
CorePlugin

@OverrideOnly public interface MarkflowPlugin
Class represents an extension to Markflow to configure how parsing and rendering of Markdown is carried on.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    This class holds registered plugins and used to set dependencies.
  • Method Summary

    Modifier and Type
    Method
    Description
    default 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
    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 to post-process parsed node (make changes for example).
    default void
    beforeSetText(TextView textView, Spanned markdown)
    This method will be called before calling TextView#setText.
    default void
    This method will be called before any other during Markflow instance construction.
    default void
    Method to configure span factories and miscellaneous used for rendering of Markdown.
    default void
    configureParser(org.commonmark.parser.Parser.Builder builder)
    Method to configure Parser (for example register custom extension, etc.).
    default void
    Method to configure MarkflowTheme that is used for rendering of Markdown.
    default void
    Method to configure node visitors used for rendering of Markdown.
    default CharSequence
    Process input Markdown text and return a CharSequence to be used in parsing stage further.
  • Method Details

    • configure

      default void configure(@NonNull MarkflowPlugin.Registry registry)
      This method will be called before any other during Markflow instance construction. Used to set dependencies and tweak certain plugin.
      Parameters:
      registry - the plugin registry
    • configureParser

      default void configureParser(@NonNull org.commonmark.parser.Parser.Builder builder)
      Method to configure Parser (for example register custom extension, etc.).
    • configureTheme

      default void configureTheme(@NonNull MarkflowTheme.Builder builder)
      Method to configure MarkflowTheme that is used for rendering of Markdown.
    • configureConfig

      default void configureConfig(@NonNull MarkflowConfig.Builder builder)
      Method to configure span factories and miscellaneous used for rendering of Markdown.
    • configureVisitor

      default void configureVisitor(@NonNull MarkflowVisitor.Builder builder)
      Method to configure node visitors used for rendering of Markdown.
    • processMarkdown

      @NonNull default CharSequence processMarkdown(@NonNull CharSequence markdown)
      Process input Markdown text and return a CharSequence to be used in parsing stage further. Can be described as pre-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

      default void beforeRender(@NonNull org.commonmark.node.Node document)
      This method will be called before rendering will occur thus making possible to post-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 modifying node 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 document
      visitor - MarkflowVisitor instance used to render Markdown
    • beforeSetText

      default void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown)
      This method will be called before calling TextView#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 which markdown will be applied
      markdown - the rendered Markdown
    • afterSetText

      default void afterSetText(@NonNull TextView textView)
      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 calling TextView#getText#getSpans.

      This method will be called from UI thread.

      Parameters:
      textView - the TextView to which markdown was applied