"Parsedown",
"version" => "0.9.9",
"author" => "Emanuil Rusev & Starbeamrainbowlabs",
"description" => "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https://github.com/erusev/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
"id" => "parser-parsedown",
"code" => function() {
global $settings;
$parser = new PeppermintParsedown();
$parser->setInternalLinkBase("?page=%s");
add_parser("parsedown", function($source) use ($parser) {
global $settings;
if($settings->clean_raw_html)
$parser->setMarkupEscaped(true);
else
$parser->setMarkupEscaped(false);
$result = $parser->text($source);
return $result;
});
// Wanted pages
statistic_add([
"id" => "wanted-pages",
"name" => "Wanted Pages",
"update" => function($old_stats) {
global $pageindex, $env;
$result = new stdClass(); // completed, value, state
$pages = [];
foreach($pageindex as $pagename => $pagedata) {
if(!file_exists($env->storage_prefix . $pagedata->filename)) {
continue;
}
$page_content = file_get_contents($env->storage_prefix . $pagedata->filename);
preg_match_all("/\[\[([^\]]+)\]\]/", $page_content, $linked_pages);
if(count($linked_pages[1]) === 0)
continue; // No linked pages here
foreach($linked_pages[1] as $linked_page) {
// Strip everything after the | and the #
if(strpos($linked_page, "|") !== false)
$linked_page = substr($linked_page, 0, strpos($linked_page, "|"));
if(strpos($linked_page, "#") !== false)
$linked_page = substr($linked_page, 0, strpos($linked_page, "#"));
if(strlen($linked_page) === 0)
continue;
// Make sure we try really hard to find this page in the
// pageindex
if(!empty($pageindex->{ucfirst($linked_page)}))
$linked_page = ucfirst($linked_page);
else if(!empty($pageindex->{ucwords($linked_page)}))
$linked_page = ucwords($linked_page);
// We're only interested in pages that don't exist
if(!empty($pageindex->$linked_page)) continue;
if(empty($pages[$linked_page]))
$pages[$linked_page] = 0;
$pages[$linked_page]++;
}
}
arsort($pages);
$result->value = $pages;
$result->completed = true;
return $result;
}
]);
add_help_section("20-parser-default", "Editor Syntax",
"
$settings->sitename's editor uses an extended version of Parsedown to render pages, which is a fantastic open source Github flavoured markdown parser. You can find a quick reference guide on Github flavoured markdown here by adam-p, or if you prefer a book Mastering Markdown by KB is a good read, and free too!
Tips
Put 2 spaces at the end of a line to add a soft line break. Leave a blank line to add a head line break (i.e. a new paragraph).
You can add an id to a header that you can link to. Put it in curly braces after the heading name like this: # Heading Name {#HeadingId}. Then you can link to like like this: [[Page name#HeadingId}]]. You can also link to a heading id on the current page by omitting the page name: [[#HeadingId]].
Extra Syntax
$settings->sitename's editor also supports some extra custom syntax, some of which is inspired by Mediawiki.
An image with a caption that fits inside a 256px x 256px box, preserving aspect ratio. The caption is taken from the alt text.
![Alt text](Files/Cheese.png)
An example of the short url syntax for images. Simply enter the page name of an image (or video / audio file), and Pepperminty Wiki will sort out the url for you.
Note that the all image image syntax above can be mixed and matched to your liking. The caption option in particular must come last or next to last.
Templating
$settings->sitename also supports including one page in another page as a template. The syntax is very similar to that of Mediawiki. For example, {{Announcement banner}} will include the contents of the \"Announcement banner\" page, assuming it exists.
You can also use variables. Again, the syntax here is very similar to that of Mediawiki - they can be referenced in the included page by surrrounding the variable name in triple curly braces (e.g. {{{Announcement text}}}), and set when including a page with the bar syntax (e.g. {{Announcement banner | importance = high | text = Maintenance has been planned for tonight.}}). Currently the only restriction in templates and variables is that you may not include a closing curly brace (}) in the page name, variable name, or value.
Special Variables
$settings->sitename also supports a number of special built-in variables. Their syntax and function are described below:
Type this
To get this
{{{@}}}
Lists all variables and their values in a table.
{{{#}}}
Shows a 'stack trace', outlining all the parent includes of the current page being parsed.
{{{~}}}
Outputs the requested page's name.
{{{*}}}
Outputs a comma separated list of all the subpages of the current page.
{{{+}}}
Shows a gallery containing all the files that are sub pages of the current page.