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

A way to override default Parsedown behavior #747

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
21 changes: 16 additions & 5 deletions system/src/Grav/Common/Markdown/ParsedownGravTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ protected function init($page, $defaults)
* @param $type
* @param $tag
*/
public function addBlockType($type, $tag, $continuable = false, $completable = false)
public function addBlockType($type, $tag, $continuable = false, $completable = false, $index = null)
{
$this->BlockTypes[$type] [] = $tag;
if (!isset($index)) {
$this->BlockTypes[$type] [] = $tag;
} else {
array_splice($this->BlockTypes[$type], $index, 0, $tag);
}

if ($continuable) {
$this->continuable_blocks[] = $tag;
Expand All @@ -82,10 +86,17 @@ public function addBlockType($type, $tag, $continuable = false, $completable = f
* @param $type
* @param $tag
*/
public function addInlineType($type, $tag)
public function addInlineType($type, $tag, $index = null)
{
$this->InlineTypes[$type] [] = $tag;
$this->inlineMarkerList .= $type;
if (!isset($index)) {
$this->InlineTypes[$type] [] = $tag;
} else {
array_splice($this->InlineTypes[$type], $index, 0, $tag);
}

if (strpos($this->inlineMarkerList, $type) === false) {
$this->inlineMarkerList .= $type;
}
}

/**
Expand Down