Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Parsedown:sub/superscript_Php_Commonmark_Parsedown - Fatal编程技术网

Php Parsedown: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文件并包含这样的语法,应该采取哪些步骤 注意:这个问题已经在其他

的当前版本没有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
文件并包含这样的语法,应该采取哪些步骤


注意:这个问题已经在其他时候出现过()。然而,仍然没有一个分步指南来解释在
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 = '!*_&[:<`~\\^';