Parsedown

repository·master·Indexed 12 days ago

https://github.com/erusev/parsedown

A fast, extensible, and dependency-free GitHub-flavored Markdown parser for PHP. It provides methods for full Markdown parsing via text() and inline parsing via line(), with built-in Safe Mode for sanitizing untrusted user input.

Tokens
440
Snippets
4
Records
5
Agent score
47%

What's inside Parsedown

  1. Parse Markdown with Parsedown

    master

    To convert Markdown text into HTML, instantiate the Parsedown class and use the text() method. For parsing only inline Markdown elements without block-level wrapping, use the line() method.

    $Parsedown = new Parsedown();
    
    // Full Markdown parsing
    echo $Parsedown->text('Hello _Parsedown_!'); # prints: <p>Hello <em>Parsedown</em>!</p>
    
    // Inline Markdown parsing only
    echo $Parsedown->line('Hello _Parsedown_!'); # prints: Hello <em>Parsedown</em>!
  2. Enable Safe Mode for untrusted user input

    master

    When processing untrusted user input, you should enable Safe Mode to escape user-provided HTML and sanitize scripting vectors (like malicious link destinations) introduced by Markdown syntax. Use setSafeMode(true) to activate this protection.

    $Parsedown->setSafeMode(true);
  3. Escape HTML in trusted input

    master

    If you are processing trusted input but want to escape any HTML tags present, use setMarkupEscaped(true).

    WARNING: This method is not safe from XSS. It does not protect against unsafe scripting vectors embedded in Markdown, such as [xss](javascript:alert%281%29).

    $Parsedown->setMarkupEscaped(true);