for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @package s9e\TextFormatter
* @copyright Copyright (c) 2010-2017 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\TextFormatter\Plugins\Litedown\Parser;
class Superscript extends AbstractParser
{
* {@inheritdoc}
protected function execute()
$pos = strpos($this->text, '^');
if ($pos === false)
return;
}
preg_match_all(
'/\\^[^\\x17\\s]++/',
$this->text,
$matches,
PREG_OFFSET_CAPTURE,
$pos
);
foreach ($matches[0] as list($match, $matchPos))
$matchLen = strlen($match);
$startTagPos = $matchPos;
$endTagPos = $matchPos + $matchLen;
$parts = explode('^', $match);
unset($parts[0]);
foreach ($parts as $part)
$this->parser->addTagPair('SUP', $startTagPos, 1, $endTagPos, 0);
$startTagPos += 1 + strlen($part);