Php Parsedown:sub/superscript
的当前版本没有sub/superscript的内置语法。尽管未指定此类语法,但其他几种轻量级标记语言(例如:,)使用的语法与以下类似:Php Parsedown:sub/superscript,php,commonmark,parsedown,Php,Commonmark,Parsedown,的当前版本没有sub/superscript的内置语法。尽管未指定此类语法,但其他几种轻量级标记语言(例如:,)使用的语法与以下类似: in: 19^th^ out: 19<sup>th</sup> in: H~2~O out: H<sub>2</sub>O in:19^th^ 外出时间:19日 in:H~2~O 输出:H2O 问题 为了修改Parsedown.php文件并包含这样的语法,应该采取哪些步骤 注意:这个问题已经在其他
in: 19^th^
out: 19<sup>th</sup>
in: H~2~O
out: H<sub>2</sub>O
in:19^th^
外出时间:19日
in:H~2~O
输出:H2O
问题为了修改
Parsedown.php
文件并包含这样的语法,应该采取哪些步骤
注意:这个问题已经在其他时候出现过()。然而,仍然没有一个分步指南来解释在
Parsedown.php
文件中应该做哪些修改才能实现这一点
$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'),
);
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',
)
),
);
}
}
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',
)
),
);
}
protected $inlineMarkerList = '!*_&[:<`~\\^';
inlineTilde
并删除方法INLINETRIKETHROW
。它看起来应该很像inlineEmphasis中的
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'),
);
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',
)
),
);
}
}
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',
)
),
);
}
protected $inlineMarkerList = '!*_&[:<`~\\^';