mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-26 05:32:59 +00:00
Add a pair of special variables to aid debugging.
This commit is contained in:
parent
42b66729b7
commit
1c6ace3492
3 changed files with 69 additions and 7 deletions
|
@ -3803,15 +3803,43 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
|
|
||||||
protected function inlineTemplate($fragment)
|
protected function inlineTemplate($fragment)
|
||||||
{
|
{
|
||||||
|
global $env;
|
||||||
|
|
||||||
// Variable parsing
|
// Variable parsing
|
||||||
if(preg_match("/\{\{\{([^}]+)\}\}\}/", $fragment["text"], $matches))
|
if(preg_match("/\{\{\{([^}]+)\}\}\}/", $fragment["text"], $matches))
|
||||||
{
|
{
|
||||||
|
$stackEntry = array_slice($this->paramStack, -1)[0];
|
||||||
|
$params = !empty($stackEntry) ? $stackEntry["params"] : false;
|
||||||
|
|
||||||
$variableKey = trim($matches[1]);
|
$variableKey = trim($matches[1]);
|
||||||
|
|
||||||
$variableValue = false;
|
$variableValue = false;
|
||||||
if(isset(array_slice($this->paramStack, -1)[0][$variableKey]))
|
switch ($variableKey)
|
||||||
{
|
{
|
||||||
$variableValue = array_slice($this->paramStack, -1)[0][$variableKey];
|
case "@":
|
||||||
|
if(!empty($params))
|
||||||
|
{
|
||||||
|
$variableValue = "<table>
|
||||||
|
<tr><th>Key</th><th>Value</th></tr>\n";
|
||||||
|
foreach($params as $key => $value)
|
||||||
|
{
|
||||||
|
$variableValue .= "\t<tr><td>" . $this->escapeText($key) . "</td><td>" . $this->escapeText($value) . "</td></tr>\n";
|
||||||
|
}
|
||||||
|
$variableValue .= "</table>";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "#":
|
||||||
|
$variableValue = "<ol start=\"0\">\n";
|
||||||
|
$variableValue .= "\t<li>$env->page</li>\n";
|
||||||
|
foreach($this->paramStack as $curStackEntry)
|
||||||
|
{
|
||||||
|
$variableValue .= "\t<li>" . $curStackEntry["pagename"] . "</li>\n";
|
||||||
|
}
|
||||||
|
$variableValue .= "</ol>\n";
|
||||||
|
}
|
||||||
|
if(isset($params[$variableKey]))
|
||||||
|
{
|
||||||
|
$variableValue = $params[$variableKey];
|
||||||
$variableValue = $this->escapeText($variableValue);
|
$variableValue = $this->escapeText($variableValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3874,7 +3902,10 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add the parsed parameters to the parameter stack
|
// Add the parsed parameters to the parameter stack
|
||||||
$this->paramStack[] = $params;
|
$this->paramStack[] = [
|
||||||
|
"pagename" => $templatePagename,
|
||||||
|
"params" => $params
|
||||||
|
];
|
||||||
|
|
||||||
$templateFilePath = $paths->storage_prefix . $pageindex->$templatePagename->filename;
|
$templateFilePath = $paths->storage_prefix . $pageindex->$templatePagename->filename;
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@
|
||||||
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
"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 a some weight to your installation, and also *requires* write access to the disk on first load.",
|
"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 a some weight to your installation, and also *requires* write access to the disk on first load.",
|
||||||
"id": "parser-parsedown",
|
"id": "parser-parsedown",
|
||||||
"lastupdate": 1458492103,
|
"lastupdate": 1458493193,
|
||||||
"optional": false
|
"optional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -81,15 +81,43 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
|
|
||||||
protected function inlineTemplate($fragment)
|
protected function inlineTemplate($fragment)
|
||||||
{
|
{
|
||||||
|
global $env;
|
||||||
|
|
||||||
// Variable parsing
|
// Variable parsing
|
||||||
if(preg_match("/\{\{\{([^}]+)\}\}\}/", $fragment["text"], $matches))
|
if(preg_match("/\{\{\{([^}]+)\}\}\}/", $fragment["text"], $matches))
|
||||||
{
|
{
|
||||||
|
$stackEntry = array_slice($this->paramStack, -1)[0];
|
||||||
|
$params = !empty($stackEntry) ? $stackEntry["params"] : false;
|
||||||
|
|
||||||
$variableKey = trim($matches[1]);
|
$variableKey = trim($matches[1]);
|
||||||
|
|
||||||
$variableValue = false;
|
$variableValue = false;
|
||||||
if(isset(array_slice($this->paramStack, -1)[0][$variableKey]))
|
switch ($variableKey)
|
||||||
{
|
{
|
||||||
$variableValue = array_slice($this->paramStack, -1)[0][$variableKey];
|
case "@":
|
||||||
|
if(!empty($params))
|
||||||
|
{
|
||||||
|
$variableValue = "<table>
|
||||||
|
<tr><th>Key</th><th>Value</th></tr>\n";
|
||||||
|
foreach($params as $key => $value)
|
||||||
|
{
|
||||||
|
$variableValue .= "\t<tr><td>" . $this->escapeText($key) . "</td><td>" . $this->escapeText($value) . "</td></tr>\n";
|
||||||
|
}
|
||||||
|
$variableValue .= "</table>";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "#":
|
||||||
|
$variableValue = "<ol start=\"0\">\n";
|
||||||
|
$variableValue .= "\t<li>$env->page</li>\n";
|
||||||
|
foreach($this->paramStack as $curStackEntry)
|
||||||
|
{
|
||||||
|
$variableValue .= "\t<li>" . $curStackEntry["pagename"] . "</li>\n";
|
||||||
|
}
|
||||||
|
$variableValue .= "</ol>\n";
|
||||||
|
}
|
||||||
|
if(isset($params[$variableKey]))
|
||||||
|
{
|
||||||
|
$variableValue = $params[$variableKey];
|
||||||
$variableValue = $this->escapeText($variableValue);
|
$variableValue = $this->escapeText($variableValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +180,10 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add the parsed parameters to the parameter stack
|
// Add the parsed parameters to the parameter stack
|
||||||
$this->paramStack[] = $params;
|
$this->paramStack[] = [
|
||||||
|
"pagename" => $templatePagename,
|
||||||
|
"params" => $params
|
||||||
|
];
|
||||||
|
|
||||||
$templateFilePath = $paths->storage_prefix . $pageindex->$templatePagename->filename;
|
$templateFilePath = $paths->storage_prefix . $pageindex->$templatePagename->filename;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue