Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParsedownGravTrait addBlockType and addInlineType enhancements #1062

Merged
merged 1 commit into from
Oct 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions system/src/Grav/Common/Markdown/ParsedownGravTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,23 @@ protected function init($page, $defaults)
*/
public function addBlockType($type, $tag, $continuable = false, $completable = false, $index = null)
{
$block = &$this->unmarkedBlockTypes;
if ($type) {
if (!isset($this->BlockTypes[$type])) {
$this->BlockTypes[$type] = [];
}
$block = &$this->BlockTypes[$type];
}

if (!isset($index)) {
$this->BlockTypes[$type] [] = $tag;
$block[] = $tag;
} else {
array_splice($this->BlockTypes[$type], $index, 0, $tag);
array_splice($block, $index, 0, [$tag]);
}

if ($continuable) {
$this->continuable_blocks[] = $tag;
}

if ($completable) {
$this->completable_blocks[] = $tag;
}
Expand All @@ -92,10 +99,10 @@ public function addBlockType($type, $tag, $continuable = false, $completable = f
*/
public function addInlineType($type, $tag, $index = null)
{
if (!isset($index)) {
if (!isset($index) || !isset($this->InlineTypes[$type])) {
$this->InlineTypes[$type] [] = $tag;
} else {
array_splice($this->InlineTypes[$type], $index, 0, $tag);
array_splice($this->InlineTypes[$type], $index, 0, [$tag]);
}

if (strpos($this->inlineMarkerList, $type) === false) {
Expand Down