1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

improve names of protected members

This commit is contained in:
Emanuil Rusev 2015-01-04 23:34:19 +02:00
parent 5639ef7d69
commit b5efe98e2f

View File

@ -113,7 +113,7 @@ class Parsedown
# ~
protected $unmarkedBlockTypes = array(
'CodeBlock',
'Code',
);
#
@ -153,7 +153,7 @@ class Parsedown
if (isset($CurrentBlock['incomplete']))
{
$Block = $this->{'addTo'.$CurrentBlock['type']}($Line, $CurrentBlock);
$Block = $this->{'block'.$CurrentBlock['type'].'Continue'}($Line, $CurrentBlock);
if (isset($Block))
{
@ -163,9 +163,9 @@ class Parsedown
}
else
{
if (method_exists($this, 'complete'.$CurrentBlock['type']))
if (method_exists($this, 'block'.$CurrentBlock['type'].'Complete'))
{
$CurrentBlock = $this->{'complete'.$CurrentBlock['type']}($CurrentBlock);
$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
}
unset($CurrentBlock['incomplete']);
@ -180,7 +180,7 @@ class Parsedown
{
foreach ($this->DefinitionTypes[$marker] as $definitionType)
{
$Definition = $this->{'identify'.$definitionType}($Line, $CurrentBlock);
$Definition = $this->{'definition'.$definitionType}($Line, $CurrentBlock);
if (isset($Definition))
{
@ -208,7 +208,7 @@ class Parsedown
foreach ($blockTypes as $blockType)
{
$Block = $this->{'identify'.$blockType}($Line, $CurrentBlock);
$Block = $this->{'block'.$blockType}($Line, $CurrentBlock);
if (isset($Block))
{
@ -221,7 +221,7 @@ class Parsedown
$Block['identified'] = true;
}
if (method_exists($this, 'addTo'.$blockType))
if (method_exists($this, 'block'.$blockType.'Continue'))
{
$Block['incomplete'] = true;
}
@ -242,7 +242,7 @@ class Parsedown
{
$Elements []= $CurrentBlock['element'];
$CurrentBlock = $this->buildParagraph($Line);
$CurrentBlock = $this->paragraph($Line);
$CurrentBlock['identified'] = true;
}
@ -250,9 +250,9 @@ class Parsedown
# ~
if (isset($CurrentBlock['incomplete']) and method_exists($this, 'complete'.$CurrentBlock['type']))
if (isset($CurrentBlock['incomplete']) and method_exists($this, 'block'.$CurrentBlock['type'].'Complete'))
{
$CurrentBlock = $this->{'complete'.$CurrentBlock['type']}($CurrentBlock);
$CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock);
}
# ~
@ -273,7 +273,7 @@ class Parsedown
#
# Atx
protected function identifyAtx($Line)
protected function blockAtx($Line)
{
if (isset($Line['text'][1]))
{
@ -301,7 +301,7 @@ class Parsedown
#
# Code
protected function identifyCodeBlock($Line, $Block = null)
protected function blockCode($Line, $Block = null)
{
if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
{
@ -327,7 +327,7 @@ class Parsedown
}
}
protected function addToCodeBlock($Line, $Block)
protected function blockCodeContinue($Line, $Block)
{
if ($Line['indent'] >= 4)
{
@ -348,7 +348,7 @@ class Parsedown
}
}
protected function completeCodeBlock($Block)
protected function blockCodeComplete($Block)
{
$text = $Block['element']['text']['text'];
@ -362,7 +362,7 @@ class Parsedown
#
# Comment
protected function identifyComment($Line)
protected function blockComment($Line)
{
if ($this->markupEscaped)
{
@ -386,7 +386,7 @@ class Parsedown
}
}
protected function addToComment($Line, array $Block)
protected function blockCommentContinue($Line, array $Block)
{
if (isset($Block['closed']))
{
@ -406,7 +406,7 @@ class Parsedown
#
# Fenced Code
protected function identifyFencedCode($Line)
protected function blockFencedCode($Line)
{
if (preg_match('/^(['.$Line['text'][0].']{3,})[ ]*([\w-]+)?[ ]*$/', $Line['text'], $matches))
{
@ -437,7 +437,7 @@ class Parsedown
}
}
protected function addToFencedCode($Line, $Block)
protected function blockFencedCodeContinue($Line, $Block)
{
if (isset($Block['complete']))
{
@ -465,7 +465,7 @@ class Parsedown
return $Block;
}
protected function completeFencedCode($Block)
protected function blockFencedCodeComplete($Block)
{
$text = $Block['element']['text']['text'];
@ -479,7 +479,7 @@ class Parsedown
#
# List
protected function identifyList($Line)
protected function blockList($Line)
{
list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
@ -508,7 +508,7 @@ class Parsedown
}
}
protected function addToList($Line, array $Block)
protected function blockListContinue($Line, array $Block)
{
if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'[ ]+(.*)/', $Line['text'], $matches))
{
@ -560,7 +560,7 @@ class Parsedown
#
# Quote
protected function identifyQuote($Line)
protected function blockQuote($Line)
{
if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
{
@ -576,7 +576,7 @@ class Parsedown
}
}
protected function addToQuote($Line, array $Block)
protected function blockQuoteContinue($Line, array $Block)
{
if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
{
@ -603,7 +603,7 @@ class Parsedown
#
# Rule
protected function identifyRule($Line)
protected function blockRule($Line)
{
if (preg_match('/^(['.$Line['text'][0].'])([ ]{0,2}\1){2,}[ ]*$/', $Line['text']))
{
@ -620,7 +620,7 @@ class Parsedown
#
# Setext
protected function identifySetext($Line, array $Block = null)
protected function blockSetext($Line, array $Block = null)
{
if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
{
@ -638,7 +638,7 @@ class Parsedown
#
# Markup
protected function identifyMarkup($Line)
protected function blockMarkup($Line)
{
if ($this->markupEscaped)
{
@ -718,7 +718,7 @@ class Parsedown
return $Block;
}
protected function addToMarkup($Line, array $Block)
protected function blockMarkupContinue($Line, array $Block)
{
if (isset($Block['closed']))
{
@ -764,7 +764,7 @@ class Parsedown
#
# Table
protected function identifyTable($Line, array $Block = null)
protected function blockTable($Line, array $Block = null)
{
if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
{
@ -871,7 +871,7 @@ class Parsedown
}
}
protected function addToTable($Line, array $Block)
protected function blockTableContinue($Line, array $Block)
{
if ($Line['text'][0] === '|' or strpos($Line['text'], '|'))
{
@ -920,7 +920,7 @@ class Parsedown
# Definitions
#
protected function identifyReference($Line)
protected function definitionReference($Line)
{
if (preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches))
{
@ -945,7 +945,7 @@ class Parsedown
# ~
#
protected function buildParagraph($Line)
protected function paragraph($Line)
{
$Block = array(
'element' => array(
@ -1038,7 +1038,7 @@ class Parsedown
# Spans
#
protected $SpanTypes = array(
protected $InlineTypes = array(
'"' => array('QuotationMark'),
'!' => array('Image'),
'&' => array('Ampersand'),
@ -1047,14 +1047,14 @@ class Parsedown
'>' => array('GreaterThan'),
'[' => array('Link'),
'_' => array('Emphasis'),
'`' => array('InlineCode'),
'`' => array('Code'),
'~' => array('Strikethrough'),
'\\' => array('EscapeSequence'),
);
# ~
protected $spanMarkerList = '!"*_&[<>`~\\';
protected $inlineMarkerList = '!"*_&[<>`~\\';
#
# ~
@ -1068,15 +1068,15 @@ class Parsedown
$markerPosition = 0;
while ($excerpt = strpbrk($remainder, $this->spanMarkerList))
while ($excerpt = strpbrk($remainder, $this->inlineMarkerList))
{
$marker = $excerpt[0];
$markerPosition += strpos($remainder, $marker);
foreach ($this->SpanTypes[$marker] as $spanType)
foreach ($this->InlineTypes[$marker] as $spanType)
{
$handler = 'identify'.$spanType;
$handler = 'inline'.$spanType;
$Span = $this->$handler($excerpt);
@ -1087,7 +1087,7 @@ class Parsedown
$plainText = substr($text, 0, $markerPosition);
$markup .= $this->readPlainText($plainText);
$markup .= $this->readUnmarkedText($plainText);
$markup .= isset($Span['markup']) ? $Span['markup'] : $this->element($Span['element']);
@ -1105,7 +1105,7 @@ class Parsedown
$markerPosition ++;
}
$markup .= $this->readPlainText($text);
$markup .= $this->readUnmarkedText($text);
return $markup;
}
@ -1114,7 +1114,7 @@ class Parsedown
# ~
#
protected function identifyAmpersand($excerpt)
protected function inlineAmpersand($excerpt)
{
if ( ! preg_match('/^&#?\w+;/', $excerpt))
{
@ -1125,7 +1125,7 @@ class Parsedown
}
}
protected function identifyStrikethrough($excerpt)
protected function inlineStrikethrough($excerpt)
{
if ( ! isset($excerpt[1]))
{
@ -1145,7 +1145,7 @@ class Parsedown
}
}
protected function identifyEscapeSequence($excerpt)
protected function inlineEscapeSequence($excerpt)
{
if (isset($excerpt[1]) and in_array($excerpt[1], $this->specialCharacters))
{
@ -1156,7 +1156,7 @@ class Parsedown
}
}
protected function identifyLessThan()
protected function inlineLessThan()
{
return array(
'markup' => '&lt;',
@ -1164,7 +1164,7 @@ class Parsedown
);
}
protected function identifyGreaterThan()
protected function inlineGreaterThan()
{
return array(
'markup' => '&gt;',
@ -1172,7 +1172,7 @@ class Parsedown
);
}
protected function identifyQuotationMark()
protected function inlineQuotationMark()
{
return array(
'markup' => '&quot;',
@ -1180,7 +1180,7 @@ class Parsedown
);
}
protected function identifyUrlTag($excerpt)
protected function inlineUrlTag($excerpt)
{
if (strpos($excerpt, '>') !== false and preg_match('/^<(https?:[\/]{2}[^\s]+?)>/i', $excerpt, $matches))
{
@ -1199,7 +1199,7 @@ class Parsedown
}
}
protected function identifyEmailTag($excerpt)
protected function inlineEmailTag($excerpt)
{
if (strpos($excerpt, '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $excerpt, $matches))
{
@ -1223,7 +1223,7 @@ class Parsedown
}
}
protected function identifyTag($excerpt)
protected function inlineTag($excerpt)
{
if ($this->markupEscaped)
{
@ -1239,7 +1239,7 @@ class Parsedown
}
}
protected function identifyInlineCode($excerpt)
protected function inlineCode($excerpt)
{
$marker = $excerpt[0];
@ -1259,7 +1259,7 @@ class Parsedown
}
}
protected function identifyImage($excerpt)
protected function inlineImage($excerpt)
{
if ( ! isset($excerpt[1]) or $excerpt[1] !== '[')
{
@ -1268,7 +1268,7 @@ class Parsedown
$excerpt = substr($excerpt, 1);
$Span = $this->identifyLink($excerpt);
$Span = $this->inlineLink($excerpt);
if ($Span === null)
{
@ -1289,7 +1289,7 @@ class Parsedown
return $Span;
}
protected function identifyLink($excerpt)
protected function inlineLink($excerpt)
{
$Element = array(
'name' => 'a',
@ -1362,7 +1362,7 @@ class Parsedown
);
}
protected function identifyEmphasis($excerpt)
protected function inlineEmphasis($excerpt)
{
if ( ! isset($excerpt[1]))
{
@ -1397,7 +1397,7 @@ class Parsedown
#
# ~
protected function readPlainText($text)
protected function readUnmarkedText($text)
{
$text = $this->linkUrls($text);