Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added syntax highlighting to README #155

Closed
wants to merge 1 commit into from

2 participants

Death_Miner Michel Fortin
Death_Miner

Added this syntax highlighting for better reading of the code snippets.

Michel Fortin
Owner

I'd rather keep Readme.md compatible with the plain Markdown parser, which has no support for fenced code blocks.

Michel Fortin michelf closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 1, 2014
  1. Death_Miner

    Added syntax highlighting

    DeathMiner authored
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 14 deletions.
  1. +25 −14 Readme.md
39 Readme.md
View
@@ -54,32 +54,39 @@ autoloading, see below.)
With class autoloading in place, putting the 'Michelf' folder in your
include path should be enough for this to work:
-
- use \Michelf\Markdown;
- $my_html = Markdown::defaultTransform($my_text);
+```php
+use \Michelf\Markdown;
+$my_html = Markdown::defaultTransform($my_text);
+```
Markdown Extra syntax is also available the same way:
- use \Michelf\MarkdownExtra;
- $my_html = MarkdownExtra::defaultTransform($my_text);
+```php
+use \Michelf\MarkdownExtra;
+$my_html = MarkdownExtra::defaultTransform($my_text);
+```
If you wish to use PHP Markdown with another text filter function
built to parse HTML, you should filter the text *after* the `transform`
function call. This is an example with [PHP SmartyPants][psp]:
- use \Michelf\Markdown, \Michelf\SmartyPants;
- $my_html = Markdown::defaultTransform($my_text);
- $my_html = SmartyPants::defaultTransform($my_html);
+```php
+use \Michelf\Markdown, \Michelf\SmartyPants;
+$my_html = Markdown::defaultTransform($my_text);
+$my_html = SmartyPants::defaultTransform($my_html);
+```
All these examples are using the static `defaultTransform` static function
found inside the parser class. If you want to customize the parser
configuration, you can also instantiate it directly and change some
configuration variables:
- use \Michelf\MarkdownExtra;
- $parser = new MarkdownExtra;
- $parser->fn_id_prefix = "post22-";
- $my_html = $parser->transform($my_text);
+```php
+use \Michelf\MarkdownExtra;
+$parser = new MarkdownExtra;
+$parser->fn_id_prefix = "post22-";
+$my_html = $parser->transform($my_text);
+```
To learn more, see the full list of [configuration variables].
@@ -91,11 +98,15 @@ To learn more, see the full list of [configuration variables].
If you cannot use class autoloading, you can still use `include` or `require`
to access the parser. To load the `\Michelf\Markdown` parser, do it this way:
- require_once 'Michelf/Markdown.inc.php';
+```php
+require_once 'Michelf/Markdown.inc.php';
+```
Or, if you need the `\Michelf\MarkdownExtra` parser:
- require_once 'Michelf/MarkdownExtra.inc.php';
+```php
+require_once 'Michelf/MarkdownExtra.inc.php';
+```
While the plain `.php` files depend on autoloading to work correctly, using the
`.inc.php` files instead will eagerly load the dependencies that would be
Something went wrong with that request. Please try again.