Class Markdown

java.lang.Object
io.mindspice.simplypages.components.Markdown
All Implemented Interfaces:
Component

public class Markdown extends Object implements Component
Markdown renderer backed by CommonMark with table extension.

Immutable and thread-safe after construction. Shared parser/renderers are stateless singletons.

Security boundary: default rendering escapes raw HTML. Use createUnsafe(String) or Markdown(String, boolean) with allowRawHtml=true only for trusted markdown sources.

  • Constructor Details

    • Markdown

      public Markdown(String markdownText)
      Creates a markdown component with safe HTML escaping.
      Parameters:
      markdownText - markdown source text
    • Markdown

      public Markdown(String markdownText, boolean allowRawHtml)
      Creates a markdown component.
      Parameters:
      markdownText - markdown source text
      allowRawHtml - when true raw HTML in markdown is emitted (unsafe for untrusted input)
  • Method Details

    • create

      public static Markdown create(String markdownText)
      Creates markdown with raw HTML escaping enabled.
      Parameters:
      markdownText - markdown source text
      Returns:
      safe markdown component
    • createUnsafe

      public static Markdown createUnsafe(String markdownText)
      Creates markdown with raw HTML passthrough.
      Parameters:
      markdownText - markdown source text from trusted origin only
      Returns:
      unsafe markdown component
    • render

      public String render(RenderContext context)
      Parses markdown and renders HTML with the configured safety mode.
      Specified by:
      render in interface Component
      Parameters:
      context - context used for slot resolution and render policy
      Returns:
      rendered HTML