Skip to content

Markdown

Viames Marino edited this page Feb 23, 2026 · 1 revision

Pair framework: Markdown

Pair\Helpers\Markdown is a lightweight Markdown-to-HTML converter.

It supports a focused subset for fast rendering and safe output.

Main method

Markdown::parse(string $markdown): string

Converts markdown text into HTML.

Supported features include:

  • headings
  • emphasis/strong
  • links/images with URL sanitization
  • inline/code blocks
  • lists
  • tables
  • basic block structures

Safety behavior

  • HTML-sensitive characters are escaped
  • URLs are sanitized by scheme (http, https, mailto, tel, #fragment)
  • dangerous schemes (e.g. javascript:) are rejected

Implementation example

$md = "# Title\n\nVisit [Pair](https://example.com).";
$html = \Pair\Helpers\Markdown::parse($md);

Render table markdown:

$md = "| Name | Value |\n|:-----|------:|\n| A | 10 |";
$html = \Pair\Helpers\Markdown::parse($md);

See also: TemplateRenderer, Utilities, View.

Clone this wiki locally