1
0
mirror of https://github.com/erusev/parsedown.git synced 2025-09-05 20:33:03 +02:00
6
Tutorial: Get Started
Daniel Rudolf edited this page 2017-08-30 09:44:22 +02:00

Installation:

Include Parsedown.php or install the composer package.

Basic usage:

echo Parsedown::instance()->text('Hello _Parsedown_!'); 

# Output:
# <p>Hello <em>Parsedown</em>!</p>

This would also work:

$Parsedown = new Parsedown();

echo $Parsedown->text('Hello _Parsedown_!'); 

# Output:
# <p>Hello <em>Parsedown</em>!</p>

Parse inline elements - instead of both block-level and inline elements:

echo Parsedown::instance()->line('Hello _Parsedown_!'); 

# Output:
# Hello <em>Parsedown</em>!

Set options:

echo Parsedown::instance()
   ->setBreaksEnabled(true) # enables automatic line breaks
   ->text("1st line \n 2nd line"); 

# Output:
# <p>1st line <br /> 2nd line</p>
echo Parsedown::instance()
   ->setMarkupEscaped(true) # escapes markup (HTML)
   ->text("<div><strong>*Some text*</strong></div>");

# Output:
# <p>&lt;div&gt;&lt;strong&gt;<em>Some text</em>&lt;/strong&gt;&lt;/div&gt;</p>
echo Parsedown::instance()
   ->setUrlsLinked(false) # prevents automatic linking of URLs
   ->text("You can find Parsedown at http://parsedown.org");

# Output:
# <p>You can find Parsedown at http://parsedown.org</p>