追加Superscript
和Tilde
在$InlineTypes
:
protected $InlineTypes = array(
'!' => array('Image'),
'&' => array('SpecialCharacter'),
'*' => array('Emphasis'),
':' => array('Url'),
'<' => array('UrlTag', 'EmailTag', 'Markup'),
'[' => array('Link'),
'_' => array('Emphasis'),
'`' => array('Code'),
'~' => array('Tilde'),
'^' => array('Superscript'),
'\\' => array('EscapeSequence'),
);
定义方法inlineSuperscript
。它应该看起来很像inlineStrikethrough
:
protected function inlineSuperscript($Excerpt)
{
if (preg_match('/^\^(.+?)\^/', $Excerpt['text'], $matches))
{
return array(
'extent' => strlen($matches[0]),
'element' => array(
'name' => 'sup',
'handler' => array(
'function' => 'lineElements',
'argument' => $matches[1],
'destination' => 'elements',
)
),
);
}
}
定义方法inlineTilde
和删除方法inlineStrikethrough
。它应该看起来很像inlineEmphasis
:
protected function inlineTilde($Excerpt)
{
if ( ! isset($Excerpt['text'][1]))
{
return;
}
$marker = $Excerpt['text'][0];
if ($Excerpt['text'][1] === $marker and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches))
{
$emphasis = 'del';
}
elseif (preg_match('/^~(?=\S)(.+?)(?<=\S)~/', $Excerpt['text'], $matches))
{
$emphasis = 'sub';
}
else
{
return;
}
return array(
'extent' => strlen($matches[0]),
'element' => array(
'name' => $emphasis,
'handler' => array(
'function' => 'lineElements',
'argument' => $matches[1],
'destination' => 'elements',
)
),
);
}
将新符号添加到$inlineMarkerList
:
protected $inlineMarkerList = '!*_&[:<`~\\^';
于 2018-08-21T22:48:59.370 回答