Fatdown, a Markdown bundle that doesn't suck too bad
Fatdown is a bundle based on the Litedown plugin which supports most of Markdown's features, plus the MediaEmbed and FancyPants plugins for media embedding and enhanced typography.
Demo
You can try the real-time JavaScript demo, or you can compare Fatdown to various Markdown implementations via the wonderful Babelmark 2.
Examples
use s9e\TextFormatter\Bundles\Fatdown as TextFormatter;
$text = '**Fatdown** implements a Markdown-like syntax plus extra Stuff(tm).';
$xml = TextFormatter::parse($text);
$html = TextFormatter::render($xml);
echo $html;
<p><strong>Fatdown</strong> implements a Markdown-like syntax plus extra Stuff™.</p>
Why Fatdown doesn't suck
Unlike the original Markdown specification and most Markdown flavours, Fatdown's HTML support does not allow JavaScript to be executed and is suitable for untrusted input.
use s9e\TextFormatter\Bundles\Fatdown as TextFormatter;
$text = '<img src="http://127.0.0.1/fake.png" onerror="alert(1)"/>';
$xml = TextFormatter::parse($text);
$html = TextFormatter::render($xml);
echo $html;
<p><img src="http://127.0.0.1/fake.png"></p>
Plugins
- Autoemail
- Autolink
- Escaper
- FancyPants
- HTMLComments
- HTMLElements
- HTMLEntities
- Litedown
- MediaEmbed
- PipeTables
- TaskLists
HTMLElements
a
with a mandatoryhref
attribute and an optionaltitle
attributesabbr
with an optionaltitle
attributeb
,em
,i
,s
,strong
,u
br
code
dl
,dt
anddd
del
andins
div
with an optionalclass
attributehr
img
with a mandatorysrc
attribute and optionalalt
andtitle
attributesrb
,rp
,rt
andrtc
for all yourruby
needsspan
with an optionalclass
attributesub
andsup
table
,tbody
,tfoot
,thead
td
with optionalcolspan
androwspan
attributesth
with optionalcolspan
,rowspan
andscope
attributes
MediaEmbed
URLs from the following sites are automatically embedded: Bandcamp, Dailymotion, Facebook, Liveleak, Soundcloud, Spotify, Twitch, Vimeo, Vine and YouTube.