Back to the module list

Markdown support

The markdown is a text language easy to write. It allow to be converted in HTML by the library.

To use it :

$md = new markdown ();
echo $md->html ($content);

The $content is the markdown text.

Actually the library supports the following options :

Blocks

  • Titles with equal sign underline (SeText) : converted to <h1>
  • Titles with dash sign underline (SeText) : converted to <h2>
  • Line starting by sharp (ATX) ###### : converted to <h6>
  • Line starting by sharp (ATX) ##### : converted to <h5>
  • Line starting by sharp (ATX) #### : converted to <h4>
  • Line starting by sharp (ATX) ### : converted to <h3>
  • Line starting by sharp (ATX) ## : converted to <h2>
  • Line starting by sharp (ATX) # : converted to <h1>
  • Line starting by sharp (ATX) == : converted to <h1>
  • Line starting by sharp (ATX) -- : converted to <h2>
  • Line starting by 4 spaces or a tab : converted to <code> block
  • Line starting by plus, dash or star and space : converted to <ul><li> block
  • Line starting by a number followed by a dot and space : converted to <ul><ol>
  • Separators: *** --- ___ * * * - - - _ _ _ :

Inline

  • Double underscores __TEXT__ : TEXT
  • Simple underscore _TEXT_ : TEXT
  • Double stars **TEXT** : TEXT
  • Simple star *TEXT* : TEXT
  • Backquotes `TEXT` : TEXT
  • Images ![Alternate text](../favicon.ico) : Alternate text
  • URL [Google Site](http://google.fr/ "With help bubble") : Google Site
  • URL [Google Site](http://google.fr/) : Google Site
  • URL <http://dominique.fournier38.fr> : http://dominique.fournier38.fr
  • URL <user@example.com> : user@example.com

The class definition

Class \markdown

Namespace \

Description

 Convert the Markdown text to html format

Properties

public $debug=false;
 To debug the markdown analyzer, activate the option

Methods

public function html ($markdown)
 Convert the markdown text to html
 @param string $markdown The markdown to convert