Skip to content

Commit

Permalink
Adding support for User Tags.
Browse files Browse the repository at this point in the history
User Tags can present these format and they're insensitive:
- /ROLE_ADMIN
- /admin
- /a
- /u/#ID
- /ROLE_USER/@USERNAME
- /ROLE_MOD/@USERNAME (they virtually do the same thing, could present changes in notification importance)
  • Loading branch information
LyesSaadi committed Jun 15, 2019
1 parent a0bf2b3 commit 21a1c13
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ParsedownHAYFlavored.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ function __construct()
$this->InlineTypes['-'][]= 'Radio';
$this->InlineTypes['['][]= 'Survey';
$this->InlineTypes['$'][] = 'InlineLaTeX';
$this->InlineTypes['/'][] = 'UserTag';
$this->BlockTypes['$'][] = 'LaTeX';
$this->BlockTypes['['][] = 'LaTeX';
$this->inlineMarkerList .= '-';
$this->inlineMarkerList .= '[';
$this->inlineMarkerList .= '$';
$this->inlineMarkerList .= '/';
}

protected function blockList($Line, ?array $CurrentBlock = NULL)
Expand Down Expand Up @@ -116,6 +118,23 @@ protected function inlineInlineLaTeX($excerpt)
}
}

protected function inlineUserTag($excerpt)
{
if (preg_match('/^\/[\w#@]+(?:[\w#@\/-]+)?/i', $excerpt['text'], $matches))
{
return array(
'extent' => strlen($matches[0]),
'element' => array(
'name' => 'span',
'text' => $matches[0],
'attributes' => array(
'class' => 'usertag_unprocessed'
)
)
);
}
}

protected function blockLaTeX($line, $block)
{
if (preg_match('/^(\$\$\$|\[LaTeX\])/i', $line['text'], $matches))
Expand Down

0 comments on commit 21a1c13

Please sign in to comment.