bef93-runner blogpost
This commit is contained in:
@@ -22,15 +22,36 @@ class ParsedownCustom extends ParsedownExtra
|
||||
|
||||
$Block['custom'] = false;
|
||||
|
||||
if (isset($Block['element']['text']['attributes']) && in_array('language-befungerunner', $Block['element']['text']['attributes']))
|
||||
if (isset($Block['element']['text']['attributes']))
|
||||
{
|
||||
$Block['element']['handler'] = 'handleBef93';
|
||||
$Block['custom'] = true;
|
||||
}
|
||||
else if (isset($Block['element']['text']['attributes']) && in_array('language-bfjoustrunner', $Block['element']['text']['attributes']))
|
||||
{
|
||||
$Block['element']['handler'] = 'handleBFJoust';
|
||||
$Block['custom'] = true;
|
||||
foreach ($Block['element']['text']['attributes'] as $attr)
|
||||
{
|
||||
$spl = explode('__', $attr);
|
||||
|
||||
if ($spl[0] === 'language-befungerunner')
|
||||
{
|
||||
$Block['element']['handler'] = 'handleBef93';
|
||||
$Block['custom'] = true;
|
||||
$Block['element']['text']['b93_speed'] = null;
|
||||
$Block['element']['text']['b93_interactive'] = true;
|
||||
$Block['element']['text']['b93_editable'] = true;
|
||||
|
||||
foreach ($spl as $param)
|
||||
{
|
||||
if (startsWith($param, 'speed-')) $Block['element']['text']['b93_speed'] = intval( substr($param, strlen('speed-')));
|
||||
if (startsWith($param, 'interactive-')) $Block['element']['text']['b93_interactive'] = boolval(substr($param, strlen('interactive-')));
|
||||
if (startsWith($param, 'editable-')) $Block['element']['text']['b93_editable'] = boolval(substr($param, strlen('editable-')));
|
||||
}
|
||||
|
||||
return $Block;
|
||||
}
|
||||
else if ($spl[0] === 'language-bfjoustrunner')
|
||||
{
|
||||
$Block['element']['handler'] = 'handleBFJoust';
|
||||
$Block['custom'] = true;
|
||||
return $Block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $Block;
|
||||
@@ -60,14 +81,15 @@ class ParsedownCustom extends ParsedownExtra
|
||||
|
||||
protected function handleBef93(array $Element)
|
||||
{
|
||||
global $PARAM_CODE;
|
||||
global $PARAM_URL;
|
||||
global $PARAM_INTERACTIVE;
|
||||
|
||||
$PARAM_CODE = $Element['text'];
|
||||
$PARAM_URL = '';
|
||||
$PARAM_INTERACTIVE = true;
|
||||
|
||||
global $PARAM_BEFUNGE93RUNNER;
|
||||
$PARAM_BEFUNGE93RUNNER =
|
||||
[
|
||||
'code' => $Element['text'],
|
||||
'url' => '',
|
||||
'interactive' => $Element['b93_interactive'],
|
||||
'speed' => $Element['b93_speed'],
|
||||
'editable' => $Element['b93_editable'],
|
||||
];
|
||||
return require (__DIR__ . '/../fragments/befunge93_runner.php');
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ class Blog
|
||||
[ 'id' => 8, 'date' => '2014-11-05', 'visible' => true, 'title' => 'Rapla Enhancement Script', 'fragment' => 'rapla_css.md', 'type' => 'markdown', 'cat' => 'blog' ],
|
||||
[ 'id' => 20, 'date' => '2015-01-09', 'visible' => true, 'title' => 'More Befunge with Project Euler', 'fragment' => 'more_euler.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 9, 'date' => '2016-10-22', 'visible' => true, 'title' => 'A complete sudoku solver in Befunge-93', 'fragment' => 'sudoku_befunge.md', 'type' => 'markdown', 'cat' => 'blog' ],
|
||||
[ 'id' => 21, 'date' => '2018-01-02', 'visible' => true, 'title' => 'A simple javascript befunge-93 runner', 'fragment' => 'js_befrunner.md', 'type' => 'markdown', 'cat' => 'blog' ],
|
||||
];
|
||||
|
||||
return array_map('self::completeSingle', $all);
|
||||
|
||||
Reference in New Issue
Block a user