parent
93b50fe484
commit
fb07b9aa83
|
@ -17,7 +17,7 @@ class Parsedown
|
|||
{
|
||||
# ~
|
||||
|
||||
const version = '1.5.0';
|
||||
const version = '1.6.0';
|
||||
|
||||
# ~
|
||||
|
||||
|
@ -107,12 +107,6 @@ class Parsedown
|
|||
|
||||
# ~
|
||||
|
||||
protected $DefinitionTypes = array(
|
||||
'[' => array('Reference'),
|
||||
);
|
||||
|
||||
# ~
|
||||
|
||||
protected $unmarkedBlockTypes = array(
|
||||
'Code',
|
||||
);
|
||||
|
@ -169,7 +163,7 @@ class Parsedown
|
|||
|
||||
# ~
|
||||
|
||||
if (isset($CurrentBlock['incomplete']))
|
||||
if (isset($CurrentBlock['continuable']))
|
||||
{
|
||||
$Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock);
|
||||
|
||||
|
@ -185,8 +179,6 @@ class Parsedown
|
|||
{
|
||||
$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
|
||||
}
|
||||
|
||||
unset($CurrentBlock['incomplete']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +218,7 @@ class Parsedown
|
|||
|
||||
if (method_exists($this, 'block'.$blockType.'Continue'))
|
||||
{
|
||||
$Block['incomplete'] = true;
|
||||
$Block['continuable'] = true;
|
||||
}
|
||||
|
||||
$CurrentBlock = $Block;
|
||||
|
@ -253,7 +245,7 @@ class Parsedown
|
|||
|
||||
# ~
|
||||
|
||||
if (isset($CurrentBlock['incomplete']) and method_exists($this, 'block'.$CurrentBlock['type'].'Complete'))
|
||||
if (isset($CurrentBlock['continuable']) and method_exists($this, 'block'.$CurrentBlock['type'].'Complete'))
|
||||
{
|
||||
$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
|
||||
}
|
||||
|
@ -394,16 +386,16 @@ class Parsedown
|
|||
|
||||
protected function blockFencedCode($Line)
|
||||
{
|
||||
if (preg_match('/^(['.$Line['text'][0].']{3,})[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches))
|
||||
if (preg_match('/^['.$Line['text'][0].']{3,}[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches))
|
||||
{
|
||||
$Element = array(
|
||||
'name' => 'code',
|
||||
'text' => '',
|
||||
);
|
||||
|
||||
if (isset($matches[2]))
|
||||
if (isset($matches[1]))
|
||||
{
|
||||
$class = 'language-'.$matches[2];
|
||||
$class = 'language-'.$matches[1];
|
||||
|
||||
$Element['attributes'] = array(
|
||||
'class' => $class,
|
||||
|
@ -673,7 +665,9 @@ class Parsedown
|
|||
|
||||
if (preg_match('/^<(\w*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
|
||||
{
|
||||
if (in_array($matches[1], $this->textLevelElements))
|
||||
$element = strtolower($matches[1]);
|
||||
|
||||
if (in_array($element, $this->textLevelElements))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -736,8 +730,6 @@ class Parsedown
|
|||
{
|
||||
$Block['closed'] = true;
|
||||
}
|
||||
|
||||
$Block['markup'] .= $matches[1];
|
||||
}
|
||||
|
||||
if (isset($Block['interrupted']))
|
||||
|
@ -989,15 +981,13 @@ class Parsedown
|
|||
{
|
||||
$markup = '';
|
||||
|
||||
$unexaminedText = $text;
|
||||
# $excerpt is based on the first occurrence of a marker
|
||||
|
||||
$markerPosition = 0;
|
||||
|
||||
while ($excerpt = strpbrk($unexaminedText, $this->inlineMarkerList))
|
||||
while ($excerpt = strpbrk($text, $this->inlineMarkerList))
|
||||
{
|
||||
$marker = $excerpt[0];
|
||||
|
||||
$markerPosition += strpos($unexaminedText, $marker);
|
||||
$markerPosition = strpos($text, $marker);
|
||||
|
||||
$Excerpt = array('text' => $excerpt, 'context' => $text);
|
||||
|
||||
|
@ -1010,34 +1000,42 @@ class Parsedown
|
|||
continue;
|
||||
}
|
||||
|
||||
if (isset($Inline['position']) and $Inline['position'] > $markerPosition) # position is ahead of marker
|
||||
# makes sure that the inline belongs to "our" marker
|
||||
|
||||
if (isset($Inline['position']) and $Inline['position'] > $markerPosition)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
# sets a default inline position
|
||||
|
||||
if ( ! isset($Inline['position']))
|
||||
{
|
||||
$Inline['position'] = $markerPosition;
|
||||
}
|
||||
|
||||
# the text that comes before the inline
|
||||
$unmarkedText = substr($text, 0, $Inline['position']);
|
||||
|
||||
# compile the unmarked text
|
||||
$markup .= $this->unmarkedText($unmarkedText);
|
||||
|
||||
# compile the inline
|
||||
$markup .= isset($Inline['markup']) ? $Inline['markup'] : $this->element($Inline['element']);
|
||||
|
||||
# remove the examined text
|
||||
$text = substr($text, $Inline['position'] + $Inline['extent']);
|
||||
|
||||
$unexaminedText = $text;
|
||||
|
||||
$markerPosition = 0;
|
||||
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$unexaminedText = substr($excerpt, 1);
|
||||
# the marker does not belong to an inline
|
||||
|
||||
$markerPosition ++;
|
||||
$unmarkedText = substr($text, 0, $markerPosition + 1);
|
||||
|
||||
$markup .= $this->unmarkedText($unmarkedText);
|
||||
|
||||
$text = substr($text, $markerPosition + 1);
|
||||
}
|
||||
|
||||
$markup .= $this->unmarkedText($text);
|
||||
|
@ -1199,7 +1197,7 @@ class Parsedown
|
|||
return;
|
||||
}
|
||||
|
||||
if (preg_match('/^[(]((?:[^ (]|[(][^ )]+[)])+)(?:[ ]+("[^"]+"|\'[^\']+\'))?[)]/', $remainder, $matches))
|
||||
if (preg_match('/^[(]((?:[^ ()]|[(][^ )]+[)])+)(?:[ ]+("[^"]*"|\'[^\']*\'))?[)]/', $remainder, $matches))
|
||||
{
|
||||
$Element['attributes']['href'] = $matches[1];
|
||||
|
||||
|
@ -1214,7 +1212,7 @@ class Parsedown
|
|||
{
|
||||
if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
|
||||
{
|
||||
$definition = $matches[1] ? $matches[1] : $Element['text'];
|
||||
$definition = strlen($matches[1]) ? $matches[1] : $Element['text'];
|
||||
$definition = strtolower($definition);
|
||||
|
||||
$extent += strlen($matches[0]);
|
||||
|
@ -1360,11 +1358,6 @@ class Parsedown
|
|||
}
|
||||
}
|
||||
|
||||
#
|
||||
# ~
|
||||
|
||||
protected $unmarkedInlineTypes = array("\n" => 'Break', '://' => 'Url');
|
||||
|
||||
# ~
|
||||
|
||||
protected function unmarkedText($text)
|
||||
|
@ -1409,7 +1402,7 @@ class Parsedown
|
|||
|
||||
if (isset($Element['handler']))
|
||||
{
|
||||
$markup .= $this->$Element['handler']($Element['text']);
|
||||
$markup .= $this->{$Element['handler']}($Element['text']);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1483,7 +1476,7 @@ class Parsedown
|
|||
return self::$instances[$name];
|
||||
}
|
||||
|
||||
$instance = new self();
|
||||
$instance = new static();
|
||||
|
||||
self::$instances[$name] = $instance;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
RELEASE=1.5.0
|
||||
RELEASE=1.6.0
|
||||
PARSEDOWN=parsedown-$RELEASE
|
||||
curl https://codeload.github.com/erusev/parsedown/tar.gz/${RELEASE} -o ${PARSEDOWN}.tar.gz
|
||||
tar xfz ${PARSEDOWN}.tar.gz --strip-components 1 ${PARSEDOWN}/Parsedown.php ${PARSEDOWN}/LICENSE.txt
|
||||
|
|
Loading…
Reference in New Issue