Package icyllis.modernui.markdown

# Class Markdown

java.lang.Object
icyllis.modernui.markdown.Markdown

public final class Markdown extends Object
Entry point of Markdown API, it provides a context for parsing and rendering Markdown.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `Markdown.Builder`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Markdown.Builder`
  `builder(Context context)`
  `Spanned`
  `convert(String input)`
  Parse Markdown text into AST and render it to Modern UI rich text.
  `static Markdown`
  `create(Context context)`
  Create with default theme and core plugin.
  `MarkdownConfig`
  `getConfig()`
  `<P extends MarkdownPlugin>
  P`
  `getPlugin(Class<P> type)`
  `@UnmodifiableView List<MarkdownPlugin>`
  `getPlugins()`
  `com.vladsch.flexmark.util.ast.Document`
  `parse(String input)`
  Parse markdown into AST.
  `Spanned`
  `render(com.vladsch.flexmark.util.ast.Node document)`
  Render the tree of nodes to Modern UI rich text.
  `<P extends MarkdownPlugin>
  P`
  `requirePlugin(Class<P> type)`
  `void`
  `setMarkdown(TextView textView, String markdown)`
  Parse Markdown text into AST, render it to Modern UI rich text, and install it to the given `TextView`.
  `void`
  `setParsedMarkdown(TextView textView, Spanned markdown)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### create

    @NonNull public static Markdown create(@NonNull Context context)
    Create with default theme and core plugin.
    Parameters:
      `context` - view context
    Returns:
      markdown inflater

  - ### builder

    @NonNull public static Markdown.Builder builder(@NonNull Context context)

  - ### parse

    @NonNull public com.vladsch.flexmark.util.ast.Document parse(@NonNull String input)
    Parse markdown into AST.
    Parameters:
      `input` - Markdown text to parse
    Returns:
      root document

  - ### render

    @NonNull public Spanned render(@NonNull com.vladsch.flexmark.util.ast.Node document)
    Render the tree of nodes to Modern UI rich text.

    Please note that returned Spanned has few limitations. For example, images, tables and ordered lists require TextView to be properly displayed. This is why images and tables most likely won\'t work in this case. Ordered lists might have mis-measurements. Whenever possible use `setMarkdown(TextView, String)` or `setParsedMarkdown(TextView, Spanned)` as these methods will additionally call specific `MarkdownPlugin` methods to prepare proper display.

    Parameters:
      `document` - the root node
    Returns:
      the rendered Spanned

  - ### convert

    @NonNull public Spanned convert(@NonNull String input)
    Parse Markdown text into AST and render it to Modern UI rich text.
    Parameters:
      `input` - the markdown text
    Returns:
      the rendered Spanned

  - ### setMarkdown

    @UiThread public void setMarkdown(@NonNull TextView textView, @NonNull String markdown)
    Parse Markdown text into AST, render it to Modern UI rich text, and install it to the given `TextView`.

    In most cases, you just need this to display Markdown. Note that you should not change TextView typography attributes after calling this.

  - ### setParsedMarkdown

    @UiThread public void setParsedMarkdown(@NonNull TextView textView, @NonNull Spanned markdown)

  - ### getPlugin

    @Nullable public <P extends MarkdownPlugin> P getPlugin(@NonNull Class<P> type)

  - ### requirePlugin

    @NonNull public <P extends MarkdownPlugin> P requirePlugin(@NonNull Class<P> type)

  - ### getPlugins

    @NonNull public @UnmodifiableView List<MarkdownPlugin> getPlugins()

  - ### getConfig

    @NonNull public MarkdownConfig getConfig()