"Old Default Parser", "version" => "0.10", "author" => "Johnny Broadway & Starbeamrainbowlabs", "description" => "The *old* default parser for Pepperminty Wiki. Based on Johnny Broadway's Slimdown (with more than a few modifications). This parser's features are documented in the help page. Superceded by a customised extension of parsedown extra.", "id" => "parser-default-old", "optional" => true, "code" => function() { global $settings; add_parser("default", function($markdown) { return Slimdown::render($markdown); }); // Register the help section if($settings->parser != "default") return; // Don't register the help section if we aren't the currently set parser. add_help_section("20-parser-default", "Editor Syntax", "
$settings->sitename's editor uses a modified version of slimdown, a flavour of markdown that is implementated using regular expressions. See the credits page for more information and links to the original source for this. A quick reference can be found below:
Type This | To get this |
---|---|
_italics_ | italics |
*bold* | bold |
~~Strikethrough~~ | |
`code` | code |
# Heading | Heading |
## Sub Heading | Sub Heading |
[[Internal Link]] | Internal Link |
[[Display Text|Internal Link]] | Display Text |
[Display text](//google.com/) | Display Text |
> Blockquote | Blockquote |
- Apples |
|
1. This is |
|
---
| |
![Alt text](//starbeamrainbowlabs.com/favicon-small.png) |
In addition, the following extra syntax is supported for images:
Size the image to at most 250 pixels wide:
![Alt text](//starbeamrainbowlabs.com/favicon-small.png 250px)
Size the image to at most 120px wide and have it float at the right ahnd size of the page:
![Alt text](//starbeamrainbowlabs.com/favicon-small.png 120px right)
");
}
]);
/***********************************************************************
* ███████ ██ ██ ███ ███ ██████ ██████ ██ ██ ███ ██ *
* ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ████ ██ *
* ███████ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ █ ██ ██ ██ ██ *
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ *
* ███████ ███████ ██ ██ ██ ██████ ██████ ███ ███ ██ ████ *
***********************************************************************/
/**
* Slimdown - A very basic regex-based Markdown parser. Supports the
* following elements (and can be extended via Slimdown::add_rule()):
*
* - Headers
* - Links
* - Bold
* - Emphasis
* - Deletions
* - Quotes
* - Inline code
* - Blockquotes
* - Ordered/unordered lists
* - Horizontal rules
*
* Author: Johnny Broadway \1', // quote '/`(.*?)`/' => '
\1
', // inline code
'/\n\s*(\*|-)(.*)/' => 'self::ul_list', // ul lists
'/\n[0-9]+\.(.*)/' => 'self::ol_list', // ol lists
'/\n(>|\>)(.*)/' => 'self::blockquote', // blockquotes
'/\n-{3,}/' => "\n/' => "\n" // fix extra blockquote ); private static function para ($regs) { $line = $regs[1]; $trimmed = trim ($line); if (preg_match ('/^<\/?(ul|ol|li|h|p|bl)/', $trimmed)) { return "\n" . $line . "\n"; } return sprintf ("\n%s
\n", $trimmed); } private static function ul_list ($regs) { $item = $regs[2]; return sprintf ("\n\n\t
", trim($item)); } private static function ol_list ($regs) { $item = $regs[1]; return sprintf ("\n- %s
\n\n\t
", trim($item)); } private static function blockquote ($regs) { $item = $regs[2]; return sprintf ("\n- %s
\n%s", trim($item)); } private static function header ($regs) { list ($tmp, $chars, $header) = $regs; $level = strlen ($chars); return sprintf ('%s ', $level + 1, trim($header), $level + 1); } /** * Add a rule. */ public static function add_rule ($regex, $replacement) { self::$rules[$regex] = $replacement; } /** * Render some Markdown into HTML. */ public static function render ($text) { foreach (self::$rules as $regex => $replacement) { if (is_callable ( $replacement)) { $text = preg_replace_callback ($regex, $replacement, $text); } else { $text = preg_replace ($regex, $replacement, $text); } } return trim ($text); } } //////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// ?>