User Tools

Site Tools


res:plugins:parsedown

Parsedown

Author: Fraenkiman, based on a fork of Emanuil Rusev

Description

Parsedown is an efficient, modern PHP implementation of Markdown syntax originally developed by John Gruber.

  • One file
  • No Dependencies
  • Super Fast

Why Parsedown? It's faster, more consistent and is being actively developed.

Parsedown passes most CommonMark tests. The tests that fail are more unusual cases. However, as CommonMark continues to evolve, compliance should improve.

Requirements

You need:

How FlatPress uses the plugin

The plugin registers Markdown parsing for:

  • entries: the_content and the_content_rss
  • excerpts: the_excerpt and the_excerpt_rss
  • comments: comment_text

FlatPress' default text formatting filters are removed before Parsedown runs, so that Markdown source is not changed into HTML paragraphs or smart typography too early.

Parser configuration in this plugin:

  • safe mode is off: Parsedown itself does not remove raw HTML
  • markup escaping is off: raw HTML is kept unless another FlatPress/BBCode save-time filter escaped it before output
  • strict mode is off: Parsedown accepts some Markdown forms more generously
  • URL linking is on: absolute http: and https: URLs are linked automatically
  • automatic line breaks are off: a normal newline inside a paragraph stays a newline; use Markdown hard-break syntax when a <br> is required

Security note: Enable raw HTML only for trusted authors. Comment text is still stored escaped by FlatPress; the plugin selectively restores only safe Markdown autolinks immediately before parsing.

Parsedown Extra availability

The plugin prefers Parsedown Extra when all of the following PHP features are available:

  • DOMDocument
  • DOMElement
  • libxml_use_internal_errors()

If these PHP features are missing, the plugin falls back to plain Parsedown. In that fallback mode, the "Parsedown Extra syntax" section below is not available. For example, # Heading {#id} will be rendered as a heading containing the literal text {#id} instead of creating an HTML id attribute.

Markdown syntax

Headers (Setext)

This is an H1 
=============== 

This is an H2 
--------------- 

Headers (atx)

# This is an H1 

## This is a H2 

###### This is a H6 

# This is a H1 # 

## This is a H2 ## 

### This is a H3 ###### 

Quotes

> This is a two paragraph quote. The customer should be very satisfied, 
> consectetuer adipiscing elit. I have decided to 
a policeman. Vestibulum enim visi, viverra nec, fringilla in, laoreet 
> vitae, risus. 
>> 
Until then, it will be fun. Some people always want to be very happy. 
> Suspendisse id sem consectetuer libero luctus adipiscing. 

> This is a two paragraph quote It is important to have good customer service, 
a customer service provider. I decided to use a policeman. 
For the vestibule, we saw: Viverra nec, Fringilla in, Laoreet vitae, 
Risus. 

> Until it's fun to play. Some people always want to be very happy. 
Suspendisse id sem consectetuer libero luctus adipiscing. 

> Today is the first day Quote level. 
> 
> > This is a nested quote 
>> 
Back to the first level 

> ## This is a headline 
> 
> 1. this is the first list item. 
> 2. this is the second list item 
> 
> Here is a small example code: 
> 
> return shell_exec("echo $input | $Markdown_script"); 

Lists

* Red 
* Green 
* Blue 

+ Red 
+ green 
+ Blue 

- red 
- green 
- blue 

1. dog 
2. cat 
3. mouse 

* Lorem ipsum dolor let amet, consectetuer adipiscing elit. 
  I decided to use a policeman. For the vestibule we have seen: 
  Viverra nec, Fringilla in, Laoreet vitae, Risus. 
* Until it's fun to play. Some people always want to be very happy. 
  Suspendisse id sem consectetuer libero luctus adipiscing. 
  
* Warsteiner 
* King 

* Warsteiner 2 

* King 2 

1 This is a list item with two paragraphs. It is important to, 
  to have good customer service, a customer service provider. I decided to, 
  to use a policeman. 

  For the vestibule, we saw: Viverra nec, Fringilla in, Laoreet 
  vitae, Risus. Until then, it will be fun. 
  Some people always want to be very happy . 

2 Suspendisse id sem consectetuer libero luctus adipiscing.


* This is a two-paragraph list item. 

 This is the second paragraph in this list item. Only the 
first line must be indented It is important to have good customer service, 
a customer service provider. 

* Another item in the same list. 

* A list item with a quote: 
    > This is a quote 
    > In a list. 

* A list item with a code example: 
    <insert code here> 

Simple tables

First Header  | Second Header
------------- | -------------
Content Cell  | Content Cell
Content Cell  | Content Cell

| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Content Cell  |
| Content Cell  | Content Cell  | 

A colon at the left of the separator line will make the column left-aligned; a colon on the right of the line will make the column right-aligned; colons at both side means the column is center-aligned.

| Item      | Value |
| --------- | -----:|
| Computer  | $1600 |
| Phone     |   $12 |
| Pipe      |    $1 | 

Tables with preformatted cells

Alignment markers: :— left aligned, —: right aligned, :—: centred

| One        | Two  |
| :--        | :--  |
| ```One```  | Two  |

| One   | Two        |
| :--   | :--        |
| One   | ```Two```  |

| One                                | Two  |
| :--                                | :--  |
| Only ```partially``` preformatted  | Two  |

| One                                                | Two  |
| :--                                                | :--  |
| Only ```partially``` preformatted but ```twice```  | Two  |

Works only with version 1.1.0 or higher

| One        | Two        |
| :--        | :--        |
| ```One```  | ```Two```  |

| One        | Two  | Three        |
| :--        | :--  | :--          |
| ```One```  | Two  | ```Three```  |

| One                                | Two        |
| :--                                | :--        |
| Only ```partially``` preformatted  | ```Two```  |

| One  | Two        | Three        |
| :--  | :--        | :--          |
| One  | ```Two```  | ```Three```  | 
This is [an example](http://example.com/ "The link title") for an inline link. 
an inline link. 

[This link](http://example.net/) has no title attribute 

There is more information on the [About me](/about/) page. 

This is [an example] [id] for a reference link 
[id]: http://example.com/ "Enter optional title here"

## Header 1 ## {#anchor}
[Link back to header 1](#anchor)
<https://example.com/>

<address@example.com> 

Emphasis

*Single asterisk* 

_Single underline_ 

**Double asterisks** 

__double underlines__ 

Lord*God*Sacrament 

This is ~~deleted text~~.

\*This text is surrounded by literal asterisks.\*

*italics*, **bold** and ***bold italics*** or 
_italic_, __bold__ and ___bold italic___ 

Code

This is a normal paragraph. 
    The tag is a code block. 

An example in AppleScript: 
    tell application "Foo" 
        beep 
    end tell

Use the `printf()` function to output text 
``Somewhere here (`) a backtick is hidden.`` 

Nobody uses ``<blink>` tags

````
<?php 
       echo "Hello";
?>
````

This is a paragraph introducing:
~~~~~~~~~~~~~~~~~~~~~
a one-line code block
~~~~~~~~~~~~~~~~~~~~~

``````````````````
another code block
``````````````````

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<p>paragraph <b>emphasis</b>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<p>paragraph <b>emphasis</b>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

Graphics

[Alternative text](https://www.flatpress.org/fp-interface/themes/official-site/imgs/fp-logo.png)
[Alternative text](https://www.flatpress.org/fp-interface/themes/official-site/imgs/fp-logo.png "Optional title")

Images

Inline image syntax looks like this:

![Alt text](https://www.flatpress.org/fp-interface/themes/official-site/imgs/fp-logo.png)
![Alt text](https://www.flatpress.org/fp-interface/themes/official-site/imgs/fp-logo.png "Optional title")

Inline image with external URL:

[![Alt text](https://www.flatpress.org/fp-interface/themes/official-site/imgs/fp-logo.png "FlatPress-Logo")](https://google.com)

Backslash masking

\*Surrounded by asterisks\* 

Bulleted lists nested in a numbered list

1. fruit 
    * Apple 
    * Banana 
2. vegetable 
    - carrot 
    - broccoli 

Horizontal Rules

* * *
***
*****
- - -

Parsedown Extra syntax

The syntax in this section works only when Parsedown Extra is active. See "Parsedown Extra availability" above.

Special attributes for headers

## Header with ID {#my-header}

## Header with class {.important}

## Header with ID and class {#my-header .important}

Then link to the header with:

[Jump to the header](#my-header)
[FlatPress](https://www.flatpress.org/){#flatpress-link .button}

![Logo](https://www.flatpress.org/fp-interface/themes/official-site/imgs/fp-logo.png){#fp-logo .logo}

This bundled Parsedown Extra implementation supports #id and .class tokens. It does not process arbitrary attributes such as lang=de.

Footnotes

Text with a footnote.[^1]

[^1]: This is the footnote text.

Footnotes are collected at the end of the parsed text.

Definition lists

Apple
: Pomaceous fruit
: Technology company

Orange
: Citrus fruit

Abbreviations

*[HTML]: Hyper Text Markup Language
*[W3C]: World Wide Web Consortium

The HTML specification is maintained by the W3C.

Abbreviation definitions are removed from the output. Matching terms are rendered as <abbr> elements.

License

MIT

Download

Changelog

2026-05-01: Version 1.1.3
  • Corrected incorrect documentation (anchor links)
  • Documentation expanded to include the Parsedown Extra syntax
2026-04-23: Version 1.1.2
  • Comments continue to be stored in a sanitized format. Only safe autolinks are restored immediately before parsing.
2026-03-25: Version 1.1.1
  • Parsedown no longer breaks up BBCode lists in comments
2026-03-04: Version 1.1.0
  • Parsedown Extra (0.9.0) added
  • Markdown support in comments
2025-12-17: Version 1.0.1
  • PHP 8.5 compatibility
2025-03-03: Version 1.0.0
  • Initial release

Support

Please ask for help on the FlatPress Forum

res/plugins/parsedown.txt · Last modified: by fraenkiman

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki