added docblocks. Refferer to #324

This commit is contained in:
Tjoosten 2015-06-24 22:52:33 +02:00
parent 8e26f45dee
commit fe96ce842c
8 changed files with 538 additions and 6 deletions

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
parsedown

4
.idea/encodings.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/parsedown.iml" filepath="$PROJECT_DIR$/.idea/parsedown.iml" />
</modules>
</component>
</project>

8
.idea/parsedown.iml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

190
.idea/workspace.xml Normal file
View File

@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="30e78689-3c83-4709-a16d-1c7897d9debc" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/Parsedown.php" afterPath="$PROJECT_DIR$/Parsedown.php" />
</list>
<ignored path="parsedown.iws" />
<ignored path=".idea/workspace.xml" />
<ignored path=".idea/dataSources.local.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FavoritesManager">
<favorites_list name="parsedown" />
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="Parsedown.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/Parsedown.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-1.6976352" vertical-offset="12450" max-vertical-offset="27405">
<caret line="774" column="7" selection-start-line="774" selection-start-column="7" selection-end-line="774" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/Parsedown.php" />
</list>
</option>
</component>
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds">
<option name="y" value="23" />
<option name="width" value="1280" />
<option name="height" value="747" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
</navigator>
<panes>
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="parsedown" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="parsedown" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="parsedown" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="options.lastSelected" value="preferences.pluginManager" />
<property name="options.splitter.main.proportions" value="0.3" />
<property name="options.splitter.details.proportions" value="0.2" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="WebServerToolWindowFactoryState" value="false" />
</component>
<component name="RunManager">
<list size="0" />
</component>
<component name="ShelveChangesManager" show_recycled="false" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="30e78689-3c83-4709-a16d-1c7897d9debc" name="Default" comment="" />
<created>1435178230776</created>
<option name="number" value="Default" />
<updated>1435178230776</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="1280" height="747" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24959612" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="Vcs.Log.UiProperties">
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
</option>
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection />
</option>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="VcsManagerConfiguration">
<option name="myTodoPanelSettings">
<TodoPanelSettings />
</option>
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="php">
<url>file://$PROJECT_DIR$/Parsedown.php</url>
<line>1575</line>
</line-breakpoint>
</breakpoints>
<option name="time" value="1" />
</breakpoint-manager>
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/Parsedown.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-1.6976352" vertical-offset="12450" max-vertical-offset="27405">
<caret line="774" column="7" selection-start-line="774" selection-start-column="7" selection-end-line="774" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
</component>
</project>

View File

@ -13,14 +13,26 @@
# #
# #
/**
* Class Parsedown
*/
class Parsedown class Parsedown
{ {
# ~ # ~
/**
* Constants: Version
*/
const version = '1.5.3'; const version = '1.5.3';
# ~ # ~
/**
* text()
*
* @param $text
* @return string
*/
function text($text) function text($text)
{ {
# make sure no definitions are set # make sure no definitions are set
@ -48,6 +60,17 @@ class Parsedown
# Setters # Setters
# #
protected $markupEscaped;
protected $breaksEnabled;
protected $urlsLinked = true;
/**
* setBreakEnabled()
*
* @param $breaksEnabled
* @return $this
*/
function setBreaksEnabled($breaksEnabled) function setBreaksEnabled($breaksEnabled)
{ {
$this->breaksEnabled = $breaksEnabled; $this->breaksEnabled = $breaksEnabled;
@ -55,8 +78,12 @@ class Parsedown
return $this; return $this;
} }
protected $breaksEnabled; /**
* setMarkupEscaped()
*
* @param $markupEscaped
* @return $this
*/
function setMarkupEscaped($markupEscaped) function setMarkupEscaped($markupEscaped)
{ {
$this->markupEscaped = $markupEscaped; $this->markupEscaped = $markupEscaped;
@ -64,8 +91,12 @@ class Parsedown
return $this; return $this;
} }
protected $markupEscaped; /**
* setUrlsLinked()
*
* @param $urlsLinked
* @return $this
*/
function setUrlsLinked($urlsLinked) function setUrlsLinked($urlsLinked)
{ {
$this->urlsLinked = $urlsLinked; $this->urlsLinked = $urlsLinked;
@ -73,12 +104,13 @@ class Parsedown
return $this; return $this;
} }
protected $urlsLinked = true;
# #
# Lines # Lines
# #
/**
* @var array
*/
protected $BlockTypes = array( protected $BlockTypes = array(
'#' => array('Header'), '#' => array('Header'),
'*' => array('Rule', 'List'), '*' => array('Rule', 'List'),
@ -107,6 +139,9 @@ class Parsedown
# ~ # ~
/**
* @var array
*/
protected $unmarkedBlockTypes = array( protected $unmarkedBlockTypes = array(
'Code', 'Code',
); );
@ -115,6 +150,12 @@ class Parsedown
# Blocks # Blocks
# #
/**
* lines()
*
* @param array $lines
* @return string
*/
private function lines(array $lines) private function lines(array $lines)
{ {
$CurrentBlock = null; $CurrentBlock = null;
@ -283,6 +324,13 @@ class Parsedown
# #
# Code # Code
/**
* blockCode()
*
* @param $Line
* @param null $Block
* @return array|null|void
*/
protected function blockCode($Line, $Block = null) protected function blockCode($Line, $Block = null)
{ {
if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted'])) if (isset($Block) and ! isset($Block['type']) and ! isset($Block['interrupted']))
@ -309,6 +357,13 @@ class Parsedown
} }
} }
/**
* blockCodeContinu()
*
* @param $Line
* @param $Block
* @return mixed
*/
protected function blockCodeContinue($Line, $Block) protected function blockCodeContinue($Line, $Block)
{ {
if ($Line['indent'] >= 4) if ($Line['indent'] >= 4)
@ -330,6 +385,12 @@ class Parsedown
} }
} }
/**
* blockCodeComplete()
*
* @param $Block
* @return mixed
*/
protected function blockCodeComplete($Block) protected function blockCodeComplete($Block)
{ {
$text = $Block['element']['text']['text']; $text = $Block['element']['text']['text'];
@ -344,6 +405,12 @@ class Parsedown
# #
# Comment # Comment
/**
* blockComment()
*
* @param $Line
* @return array|void
*/
protected function blockComment($Line) protected function blockComment($Line)
{ {
if ($this->markupEscaped) if ($this->markupEscaped)
@ -366,6 +433,13 @@ class Parsedown
} }
} }
/**
* BlockCommentContinue()
*
* @param $Line
* @param array $Block
* @return array|void
*/
protected function blockCommentContinue($Line, array $Block) protected function blockCommentContinue($Line, array $Block)
{ {
if (isset($Block['closed'])) if (isset($Block['closed']))
@ -386,6 +460,12 @@ class Parsedown
# #
# Fenced Code # Fenced Code
/**
* blockFencedCode()
*
* @param $Line
* @return array
*/
protected function blockFencedCode($Line) 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))
@ -417,6 +497,12 @@ class Parsedown
} }
} }
/**
* blockFencedCodeContinue()
*
* @param $Line
* @param $Block
*/
protected function blockFencedCodeContinue($Line, $Block) protected function blockFencedCodeContinue($Line, $Block)
{ {
if (isset($Block['complete'])) if (isset($Block['complete']))
@ -445,6 +531,12 @@ class Parsedown
return $Block; return $Block;
} }
/**
* blockFencedCodeComplete()
*
* @param $Block
* @return mixed
*/
protected function blockFencedCodeComplete($Block) protected function blockFencedCodeComplete($Block)
{ {
$text = $Block['element']['text']['text']; $text = $Block['element']['text']['text'];
@ -459,6 +551,12 @@ class Parsedown
# #
# Header # Header
/**
* blockHeader()
*
* @param $Line
* @return array|void
*/
protected function blockHeader($Line) protected function blockHeader($Line)
{ {
if (isset($Line['text'][1])) if (isset($Line['text'][1]))
@ -492,6 +590,12 @@ class Parsedown
# #
# List # List
/**
* blockList()
*
* @param $Line
* @return array
*/
protected function blockList($Line) protected function blockList($Line)
{ {
list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]'); list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]+[.]');
@ -521,6 +625,13 @@ class Parsedown
} }
} }
/**
* blockListContinue()
*
* @param $Line
* @param array $Block
* @return array
*/
protected function blockListContinue($Line, array $Block) protected function blockListContinue($Line, array $Block)
{ {
if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)) if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches))
@ -580,6 +691,12 @@ class Parsedown
# #
# Quote # Quote
/**
* blockQuote()
*
* @param $Line
* @return array
*/
protected function blockQuote($Line) protected function blockQuote($Line)
{ {
if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) if (preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
@ -596,6 +713,13 @@ class Parsedown
} }
} }
/**
* blockQuoteContinue()
*
* @param $Line
* @param array $Block
* @return array
*/
protected function blockQuoteContinue($Line, array $Block) protected function blockQuoteContinue($Line, array $Block)
{ {
if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches))
@ -623,6 +747,12 @@ class Parsedown
# #
# Rule # Rule
/**
* blockRule()
*
* @param $Line
* @return array
*/
protected function blockRule($Line) protected function blockRule($Line)
{ {
if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text'])) if (preg_match('/^(['.$Line['text'][0].'])([ ]*\1){2,}[ ]*$/', $Line['text']))
@ -640,6 +770,13 @@ class Parsedown
# #
# Setext # Setext
/**
* blockSetextHeader()
*
* @param $Line
* @param array $Block
* @return array|void
*/
protected function blockSetextHeader($Line, array $Block = null) protected function blockSetextHeader($Line, array $Block = null)
{ {
if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
@ -658,6 +795,12 @@ class Parsedown
# #
# Markup # Markup
/**
* blockMarkup()
*
* @param $Line
* @return array|void
*/
protected function blockMarkup($Line) protected function blockMarkup($Line)
{ {
if ($this->markupEscaped) if ($this->markupEscaped)
@ -708,6 +851,13 @@ class Parsedown
} }
} }
/**
* blockMarkupContinue()
*
* @param $Line
* @param array $Block
* @return array|void
*/
protected function blockMarkupContinue($Line, array $Block) protected function blockMarkupContinue($Line, array $Block)
{ {
if (isset($Block['closed'])) if (isset($Block['closed']))
@ -747,6 +897,12 @@ class Parsedown
# #
# Reference # Reference
/**
* blockReference()
*
* @param $Line
* @return array
*/
protected function blockReference($Line) protected function blockReference($Line)
{ {
if (preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches)) if (preg_match('/^\[(.+?)\]:[ ]*<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*$/', $Line['text'], $matches))
@ -776,6 +932,13 @@ class Parsedown
# #
# Table # Table
/**
* blockTable()
*
* @param $Line
* @param array $Block
* @return array|void
*/
protected function blockTable($Line, array $Block = null) protected function blockTable($Line, array $Block = null)
{ {
if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) if ( ! isset($Block) or isset($Block['type']) or isset($Block['interrupted']))
@ -883,6 +1046,13 @@ class Parsedown
} }
} }
/**
* blockTableContinue()
*
* @param $Line
* @param array $Block
* @return array|void
*/
protected function blockTableContinue($Line, array $Block) protected function blockTableContinue($Line, array $Block)
{ {
if (isset($Block['interrupted'])) if (isset($Block['interrupted']))
@ -937,6 +1107,10 @@ class Parsedown
# ~ # ~
# #
/**
* @param $Line
* @return array
*/
protected function paragraph($Line) protected function paragraph($Line)
{ {
$Block = array( $Block = array(
@ -954,6 +1128,9 @@ class Parsedown
# Inline Elements # Inline Elements
# #
/**
* @var array
*/
protected $InlineTypes = array( protected $InlineTypes = array(
'"' => array('SpecialCharacter'), '"' => array('SpecialCharacter'),
'!' => array('Image'), '!' => array('Image'),
@ -971,12 +1148,21 @@ class Parsedown
# ~ # ~
/**
* @var string
*/
protected $inlineMarkerList = '!"*_&[:<>`~\\'; protected $inlineMarkerList = '!"*_&[:<>`~\\';
# #
# ~ # ~
# #
/**
* line()
*
* @param $text
* @return string
*/
public function line($text) public function line($text)
{ {
$markup = ''; $markup = '';
@ -1041,6 +1227,12 @@ class Parsedown
# ~ # ~
# #
/**
* inlineCode()
*
* @param $Excerpt
* @return array
*/
protected function inlineCode($Excerpt) protected function inlineCode($Excerpt)
{ {
$marker = $Excerpt['text'][0]; $marker = $Excerpt['text'][0];
@ -1061,6 +1253,12 @@ class Parsedown
} }
} }
/**
* inlineEmailTag()
*
* @param $Excerpt
* @return array
*/
protected function inlineEmailTag($Excerpt) protected function inlineEmailTag($Excerpt)
{ {
if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches)) if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches))
@ -1085,6 +1283,12 @@ class Parsedown
} }
} }
/**
* inlineEmphasis()
*
* @param $Excerpt
* @return array|void
*/
protected function inlineEmphasis($Excerpt) protected function inlineEmphasis($Excerpt)
{ {
if ( ! isset($Excerpt['text'][1])) if ( ! isset($Excerpt['text'][1]))
@ -1117,6 +1321,12 @@ class Parsedown
); );
} }
/**
* inlineEscapeSequence()
*
* @param $Excerpt
* @return array
*/
protected function inlineEscapeSequence($Excerpt) protected function inlineEscapeSequence($Excerpt)
{ {
if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters))
@ -1128,6 +1338,12 @@ class Parsedown
} }
} }
/**
* inlineImage()
*
* @param $Excerpt
* @return array|void
*/
protected function inlineImage($Excerpt) protected function inlineImage($Excerpt)
{ {
if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
@ -1162,6 +1378,12 @@ class Parsedown
return $Inline; return $Inline;
} }
/**
* inlineLink()
*
* @param $Excerpt
* @return array|void
*/
protected function inlineLink($Excerpt) protected function inlineLink($Excerpt)
{ {
$Element = array( $Element = array(
@ -1235,6 +1457,12 @@ class Parsedown
); );
} }
/**
* inlineMarkup()
*
* @param $Excerpt
* @return array|void
*/
protected function inlineMarkup($Excerpt) protected function inlineMarkup($Excerpt)
{ {
if ($this->markupEscaped or strpos($Excerpt['text'], '>') === false) if ($this->markupEscaped or strpos($Excerpt['text'], '>') === false)
@ -1267,6 +1495,12 @@ class Parsedown
} }
} }
/**
* inlineSpecialCharacter()
*
* @param $Excerpt
* @return array
*/
protected function inlineSpecialCharacter($Excerpt) protected function inlineSpecialCharacter($Excerpt)
{ {
if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text'])) if ($Excerpt['text'][0] === '&' and ! preg_match('/^&#?\w+;/', $Excerpt['text']))
@ -1288,6 +1522,12 @@ class Parsedown
} }
} }
/**
* inlineStrikethrough()
*
* @param $Excerpt
* @return array|void
*/
protected function inlineStrikethrough($Excerpt) protected function inlineStrikethrough($Excerpt)
{ {
if ( ! isset($Excerpt['text'][1])) if ( ! isset($Excerpt['text'][1]))
@ -1308,6 +1548,12 @@ class Parsedown
} }
} }
/**
* inlineUrl()
*
* @param $Excerpt
* @return array|void
*/
protected function inlineUrl($Excerpt) protected function inlineUrl($Excerpt)
{ {
if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
@ -1333,6 +1579,12 @@ class Parsedown
} }
} }
/**
* inlineUrlTag()
*
* @param $Excerpt
* @return array
*/
protected function inlineUrlTag($Excerpt) protected function inlineUrlTag($Excerpt)
{ {
if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches)) if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches))
@ -1354,6 +1606,12 @@ class Parsedown
# ~ # ~
/**
* unmarkedText()
*
* @param $text
* @return mixed
*/
protected function unmarkedText($text) protected function unmarkedText($text)
{ {
if ($this->breaksEnabled) if ($this->breaksEnabled)
@ -1373,6 +1631,12 @@ class Parsedown
# Handlers # Handlers
# #
/**
* element()
*
* @param array $Element
* @return string
*/
protected function element(array $Element) protected function element(array $Element)
{ {
$markup = '<'.$Element['name']; $markup = '<'.$Element['name'];
@ -1413,6 +1677,12 @@ class Parsedown
return $markup; return $markup;
} }
/**
* elements()
*
* @param array $Elements
* @return string
*/
protected function elements(array $Elements) protected function elements(array $Elements)
{ {
$markup = ''; $markup = '';
@ -1429,6 +1699,12 @@ class Parsedown
# ~ # ~
/**
* li()
*
* @param $lines
* @return mixed|string
*/
protected function li($lines) protected function li($lines)
{ {
$markup = $this->lines($lines); $markup = $this->lines($lines);
@ -1452,6 +1728,12 @@ class Parsedown
# Deprecated Methods # Deprecated Methods
# #
/**
* parse()
*
* @param $text
* @return string
*/
function parse($text) function parse($text)
{ {
$markup = $this->text($text); $markup = $this->text($text);
@ -1463,6 +1745,10 @@ class Parsedown
# Static Methods # Static Methods
# #
/**
* @param string $name
* @return Parsedown
*/
static function instance($name = 'default') static function instance($name = 'default')
{ {
if (isset(self::$instances[$name])) if (isset(self::$instances[$name]))
@ -1477,37 +1763,61 @@ class Parsedown
return $instance; return $instance;
} }
/**
* @var array
*/
private static $instances = array(); private static $instances = array();
# #
# Fields # Fields
# #
/**
* @var
*/
protected $DefinitionData; protected $DefinitionData;
# #
# Read-Only # Read-Only
/**
* @var array
*/
protected $specialCharacters = array( protected $specialCharacters = array(
'\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|',
); );
/**
* @var array
*/
protected $StrongRegex = array( protected $StrongRegex = array(
'*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s', '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s',
'_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us', '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us',
); );
/**
* @var array
*/
protected $EmRegex = array( protected $EmRegex = array(
'*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s',
'_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us', '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us',
); );
/**
* @var string
*/
protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?'; protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?';
/**
* @var array
*/
protected $voidElements = array( protected $voidElements = array(
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source',
); );
/**
* @var array
*/
protected $textLevelElements = array( protected $textLevelElements = array(
'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',