Repository: erusev/parsedown
Branch: master
Commit: 4e433a8d5707
Files: 77
Total size: 88.7 KB
Directory structure:
gitextract_8dv4ybdv/
├── .gitattributes
├── .github/
│ └── workflows/
│ └── unit-tests.yaml
├── .gitignore
├── LICENSE.txt
├── Parsedown.php
├── composer.json
├── phpunit.xml.dist
├── readme.md
└── test/
├── CommonMarkTestStrict.php
├── CommonMarkTestWeak.php
├── ParsedownTest.php
├── SampleExtensions.php
├── TestParsedown.php
└── data/
├── aesthetic_table.html
├── aligned_table.html
├── atx_heading.html
├── automatic_link.html
├── block-level_html.html
├── code_block.html
├── code_span.html
├── compound_blockquote.html
├── compound_emphasis.html
├── compound_list.html
├── deeply_nested_list.html
├── em_strong.html
├── email.html
├── emphasis.html
├── escaping.html
├── fenced_code_block.html
├── horizontal_rule.html
├── html_comment.html
├── html_entity.html
├── image_reference.html
├── image_title.html
├── implicit_reference.html
├── inline_link.html
├── inline_link_title.html
├── inline_title.html
├── lazy_blockquote.html
├── lazy_list.html
├── line_break.html
├── markup_consecutive_one.html
├── markup_consecutive_one_line.html
├── markup_consecutive_one_stripped.html
├── markup_consecutive_two.html
├── markup_consecutive_two_lines.html
├── markup_consecutive_two_stripped.html
├── multiline_list_paragraph.html
├── multiline_lists.html
├── nested_block-level_html.html
├── ordered_list.html
├── paragraph_list.html
├── reference_title.html
├── self-closing_html.html
├── separated_nested_list.html
├── setext_header.html
├── setext_header_spaces.html
├── simple_blockquote.html
├── simple_table.html
├── span-level_html.html
├── sparse_dense_list.html
├── sparse_html.html
├── sparse_list.html
├── special_characters.html
├── strict_atx_heading.html
├── strikethrough.html
├── strong_em.html
├── tab-indented_code_block.html
├── table_inline_markdown.html
├── text_reference.html
├── unordered_list.html
├── untidy_table.html
├── url_autolinking.html
├── whitespace.html
├── xss_attribute_encoding.html
├── xss_bad_url.html
└── xss_text_encoding.html
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Ignore all tests for archive
/test export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
================================================
FILE: .github/workflows/unit-tests.yaml
================================================
on:
- push
- pull_request
jobs:
phpunit:
runs-on: ubuntu-latest
strategy:
matrix:
php:
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
- '8.4'
steps:
- name: Checkout the source code
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
- name: Install dependencies
run: composer install
- name: Run tests
run: |
vendor/bin/phpunit
vendor/bin/phpunit test/CommonMarkTestWeak.php || true
================================================
FILE: .gitignore
================================================
*.md
!readme.md
composer.lock
vendor/
.phpunit.result.cache
================================================
FILE: LICENSE.txt
================================================
The MIT License (MIT)
Copyright (c) 2013-2018 Emanuil Rusev, erusev.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: Parsedown.php
================================================
<?php
#
#
# Parsedown
# http://parsedown.org
#
# (c) Emanuil Rusev
# http://erusev.com
#
# For the full license information, view the LICENSE file that was distributed
# with this source code.
#
#
class Parsedown
{
# ~
const version = '1.8.0';
# ~
function text($text)
{
$Elements = $this->textElements($text);
# convert to markup
$markup = $this->elements($Elements);
# trim line breaks
$markup = trim($markup, "\n");
return $markup;
}
protected function textElements($text)
{
# make sure no definitions are set
$this->DefinitionData = array();
# standardize line breaks
$text = str_replace(array("\r\n", "\r"), "\n", $text);
# remove surrounding line breaks
$text = trim($text, "\n");
# split text into lines
$lines = explode("\n", $text);
# iterate through lines to identify blocks
return $this->linesElements($lines);
}
#
# Setters
#
function setBreaksEnabled($breaksEnabled)
{
$this->breaksEnabled = $breaksEnabled;
return $this;
}
protected $breaksEnabled;
function setMarkupEscaped($markupEscaped)
{
$this->markupEscaped = $markupEscaped;
return $this;
}
protected $markupEscaped;
function setUrlsLinked($urlsLinked)
{
$this->urlsLinked = $urlsLinked;
return $this;
}
protected $urlsLinked = true;
function setSafeMode($safeMode)
{
$this->safeMode = (bool) $safeMode;
return $this;
}
protected $safeMode;
function setStrictMode($strictMode)
{
$this->strictMode = (bool) $strictMode;
return $this;
}
protected $strictMode;
protected $safeLinksWhitelist = array(
'http://',
'https://',
'ftp://',
'ftps://',
'mailto:',
'tel:',
'data:image/png;base64,',
'data:image/gif;base64,',
'data:image/jpeg;base64,',
'irc:',
'ircs:',
'git:',
'ssh:',
'news:',
'steam:',
);
#
# Lines
#
protected $BlockTypes = array(
'#' => array('Header'),
'*' => array('Rule', 'List'),
'+' => array('List'),
'-' => array('SetextHeader', 'Table', 'Rule', 'List'),
'0' => array('List'),
'1' => array('List'),
'2' => array('List'),
'3' => array('List'),
'4' => array('List'),
'5' => array('List'),
'6' => array('List'),
'7' => array('List'),
'8' => array('List'),
'9' => array('List'),
':' => array('Table'),
'<' => array('Comment', 'Markup'),
'=' => array('SetextHeader'),
'>' => array('Quote'),
'[' => array('Reference'),
'_' => array('Rule'),
'`' => array('FencedCode'),
'|' => array('Table'),
'~' => array('FencedCode'),
);
# ~
protected $unmarkedBlockTypes = array(
'Code',
);
#
# Blocks
#
protected function lines(array $lines)
{
return $this->elements($this->linesElements($lines));
}
protected function linesElements(array $lines)
{
$Elements = array();
$CurrentBlock = null;
foreach ($lines as $line)
{
if (chop($line) === '')
{
if (isset($CurrentBlock))
{
$CurrentBlock['interrupted'] = (isset($CurrentBlock['interrupted'])
? $CurrentBlock['interrupted'] + 1 : 1
);
}
continue;
}
while (($beforeTab = strstr($line, "\t", true)) !== false)
{
$shortage = 4 - mb_strlen($beforeTab, 'utf-8') % 4;
$line = $beforeTab
. str_repeat(' ', $shortage)
. substr($line, strlen($beforeTab) + 1)
;
}
$indent = strspn($line, ' ');
$text = $indent > 0 ? substr($line, $indent) : $line;
# ~
$Line = array('body' => $line, 'indent' => $indent, 'text' => $text);
# ~
if (isset($CurrentBlock['continuable']))
{
$methodName = 'block' . $CurrentBlock['type'] . 'Continue';
$Block = $this->$methodName($Line, $CurrentBlock);
if (isset($Block))
{
$CurrentBlock = $Block;
continue;
}
else
{
if ($this->isBlockCompletable($CurrentBlock['type']))
{
$methodName = 'block' . $CurrentBlock['type'] . 'Complete';
$CurrentBlock = $this->$methodName($CurrentBlock);
}
}
}
# ~
$marker = $text[0];
# ~
$blockTypes = $this->unmarkedBlockTypes;
if (isset($this->BlockTypes[$marker]))
{
foreach ($this->BlockTypes[$marker] as $blockType)
{
$blockTypes []= $blockType;
}
}
#
# ~
foreach ($blockTypes as $blockType)
{
$Block = $this->{"block$blockType"}($Line, $CurrentBlock);
if (isset($Block))
{
$Block['type'] = $blockType;
if ( ! isset($Block['identified']))
{
if (isset($CurrentBlock))
{
$Elements[] = $this->extractElement($CurrentBlock);
}
$Block['identified'] = true;
}
if ($this->isBlockContinuable($blockType))
{
$Block['continuable'] = true;
}
$CurrentBlock = $Block;
continue 2;
}
}
# ~
if (isset($CurrentBlock) and $CurrentBlock['type'] === 'Paragraph')
{
$Block = $this->paragraphContinue($Line, $CurrentBlock);
}
if (isset($Block))
{
$CurrentBlock = $Block;
}
else
{
if (isset($CurrentBlock))
{
$Elements[] = $this->extractElement($CurrentBlock);
}
$CurrentBlock = $this->paragraph($Line);
$CurrentBlock['identified'] = true;
}
}
# ~
if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type']))
{
$methodName = 'block' . $CurrentBlock['type'] . 'Complete';
$CurrentBlock = $this->$methodName($CurrentBlock);
}
# ~
if (isset($CurrentBlock))
{
$Elements[] = $this->extractElement($CurrentBlock);
}
# ~
return $Elements;
}
protected function extractElement(array $Component)
{
if ( ! isset($Component['element']))
{
if (isset($Component['markup']))
{
$Component['element'] = array('rawHtml' => $Component['markup']);
}
elseif (isset($Component['hidden']))
{
$Component['element'] = array();
}
}
return $Component['element'];
}
protected function isBlockContinuable($Type)
{
return method_exists($this, 'block' . $Type . 'Continue');
}
protected function isBlockCompletable($Type)
{
return method_exists($this, 'block' . $Type . 'Complete');
}
#
# Code
protected function blockCode($Line, $Block = null)
{
if (isset($Block) and $Block['type'] === 'Paragraph' and ! isset($Block['interrupted']))
{
return;
}
if ($Line['indent'] >= 4)
{
$text = substr($Line['body'], 4);
$Block = array(
'element' => array(
'name' => 'pre',
'element' => array(
'name' => 'code',
'text' => $text,
),
),
);
return $Block;
}
}
protected function blockCodeContinue($Line, $Block)
{
if ($Line['indent'] >= 4)
{
if (isset($Block['interrupted']))
{
$Block['element']['element']['text'] .= str_repeat("\n", $Block['interrupted']);
unset($Block['interrupted']);
}
$Block['element']['element']['text'] .= "\n";
$text = substr($Line['body'], 4);
$Block['element']['element']['text'] .= $text;
return $Block;
}
}
protected function blockCodeComplete($Block)
{
return $Block;
}
#
# Comment
protected function blockComment($Line)
{
if ($this->markupEscaped or $this->safeMode)
{
return;
}
if (strpos($Line['text'], '<!--') === 0)
{
$Block = array(
'element' => array(
'rawHtml' => $Line['body'],
'autobreak' => true,
),
);
if (strpos($Line['text'], '-->') !== false)
{
$Block['closed'] = true;
}
return $Block;
}
}
protected function blockCommentContinue($Line, array $Block)
{
if (isset($Block['closed']))
{
return;
}
$Block['element']['rawHtml'] .= "\n" . $Line['body'];
if (strpos($Line['text'], '-->') !== false)
{
$Block['closed'] = true;
}
return $Block;
}
#
# Fenced Code
protected function blockFencedCode($Line)
{
$marker = $Line['text'][0];
$openerLength = strspn($Line['text'], $marker);
if ($openerLength < 3)
{
return;
}
$infostring = trim(substr($Line['text'], $openerLength), "\t ");
if (strpos($infostring, '`') !== false)
{
return;
}
$Element = array(
'name' => 'code',
'text' => '',
);
if ($infostring !== '')
{
/**
* https://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes
* Every HTML element may have a class attribute specified.
* The attribute, if specified, must have a value that is a set
* of space-separated tokens representing the various classes
* that the element belongs to.
* [...]
* The space characters, for the purposes of this specification,
* are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab),
* U+000A LINE FEED (LF), U+000C FORM FEED (FF), and
* U+000D CARRIAGE RETURN (CR).
*/
$language = substr($infostring, 0, strcspn($infostring, " \t\n\f\r"));
$Element['attributes'] = array('class' => "language-$language");
}
$Block = array(
'char' => $marker,
'openerLength' => $openerLength,
'element' => array(
'name' => 'pre',
'element' => $Element,
),
);
return $Block;
}
protected function blockFencedCodeContinue($Line, $Block)
{
if (isset($Block['complete']))
{
return;
}
if (isset($Block['interrupted']))
{
$Block['element']['element']['text'] .= str_repeat("\n", $Block['interrupted']);
unset($Block['interrupted']);
}
if (($len = strspn($Line['text'], $Block['char'])) >= $Block['openerLength']
and chop(substr($Line['text'], $len), ' ') === ''
) {
$Block['element']['element']['text'] = substr($Block['element']['element']['text'], 1);
$Block['complete'] = true;
return $Block;
}
$Block['element']['element']['text'] .= "\n" . $Line['body'];
return $Block;
}
protected function blockFencedCodeComplete($Block)
{
return $Block;
}
#
# Header
protected function blockHeader($Line)
{
$level = strspn($Line['text'], '#');
if ($level > 6)
{
return;
}
$text = trim($Line['text'], '#');
if ($this->strictMode and isset($text[0]) and $text[0] !== ' ')
{
return;
}
$text = trim($text, ' ');
$Block = array(
'element' => array(
'name' => 'h' . $level,
'handler' => array(
'function' => 'lineElements',
'argument' => $text,
'destination' => 'elements',
)
),
);
return $Block;
}
#
# List
protected function blockList($Line, ?array $CurrentBlock = null)
{
list($name, $pattern) = $Line['text'][0] <= '-' ? array('ul', '[*+-]') : array('ol', '[0-9]{1,9}+[.\)]');
if (preg_match('/^('.$pattern.'([ ]++|$))(.*+)/', $Line['text'], $matches))
{
$contentIndent = strlen($matches[2]);
if ($contentIndent >= 5)
{
$contentIndent -= 1;
$matches[1] = substr($matches[1], 0, -$contentIndent);
$matches[3] = str_repeat(' ', $contentIndent) . $matches[3];
}
elseif ($contentIndent === 0)
{
$matches[1] .= ' ';
}
$markerWithoutWhitespace = strstr($matches[1], ' ', true);
$Block = array(
'indent' => $Line['indent'],
'pattern' => $pattern,
'data' => array(
'type' => $name,
'marker' => $matches[1],
'markerType' => ($name === 'ul' ? $markerWithoutWhitespace : substr($markerWithoutWhitespace, -1)),
),
'element' => array(
'name' => $name,
'elements' => array(),
),
);
$Block['data']['markerTypeRegex'] = preg_quote($Block['data']['markerType'], '/');
if ($name === 'ol')
{
$listStart = ltrim(strstr($matches[1], $Block['data']['markerType'], true), '0') ?: '0';
if ($listStart !== '1')
{
if (
isset($CurrentBlock)
and $CurrentBlock['type'] === 'Paragraph'
and ! isset($CurrentBlock['interrupted'])
) {
return;
}
$Block['element']['attributes'] = array('start' => $listStart);
}
}
$Block['li'] = array(
'name' => 'li',
'handler' => array(
'function' => 'li',
'argument' => !empty($matches[3]) ? array($matches[3]) : array(),
'destination' => 'elements'
)
);
$Block['element']['elements'] []= & $Block['li'];
return $Block;
}
}
protected function blockListContinue($Line, array $Block)
{
if (isset($Block['interrupted']) and empty($Block['li']['handler']['argument']))
{
return null;
}
$requiredIndent = ($Block['indent'] + strlen($Block['data']['marker']));
if ($Line['indent'] < $requiredIndent
and (
(
$Block['data']['type'] === 'ol'
and preg_match('/^[0-9]++'.$Block['data']['markerTypeRegex'].'(?:[ ]++(.*)|$)/', $Line['text'], $matches)
) or (
$Block['data']['type'] === 'ul'
and preg_match('/^'.$Block['data']['markerTypeRegex'].'(?:[ ]++(.*)|$)/', $Line['text'], $matches)
)
)
) {
if (isset($Block['interrupted']))
{
$Block['li']['handler']['argument'] []= '';
$Block['loose'] = true;
unset($Block['interrupted']);
}
unset($Block['li']);
$text = isset($matches[1]) ? $matches[1] : '';
$Block['indent'] = $Line['indent'];
$Block['li'] = array(
'name' => 'li',
'handler' => array(
'function' => 'li',
'argument' => array($text),
'destination' => 'elements'
)
);
$Block['element']['elements'] []= & $Block['li'];
return $Block;
}
elseif ($Line['indent'] < $requiredIndent and $this->blockList($Line))
{
return null;
}
if ($Line['text'][0] === '[' and $this->blockReference($Line))
{
return $Block;
}
if ($Line['indent'] >= $requiredIndent)
{
if (isset($Block['interrupted']))
{
$Block['li']['handler']['argument'] []= '';
$Block['loose'] = true;
unset($Block['interrupted']);
}
$text = substr($Line['body'], $requiredIndent);
$Block['li']['handler']['argument'] []= $text;
return $Block;
}
if ( ! isset($Block['interrupted']))
{
$text = preg_replace('/^[ ]{0,'.$requiredIndent.'}+/', '', $Line['body']);
$Block['li']['handler']['argument'] []= $text;
return $Block;
}
}
protected function blockListComplete(array $Block)
{
if (isset($Block['loose']))
{
foreach ($Block['element']['elements'] as &$li)
{
if (end($li['handler']['argument']) !== '')
{
$li['handler']['argument'] []= '';
}
}
}
return $Block;
}
#
# Quote
protected function blockQuote($Line)
{
if (preg_match('/^>[ ]?+(.*+)/', $Line['text'], $matches))
{
$Block = array(
'element' => array(
'name' => 'blockquote',
'handler' => array(
'function' => 'linesElements',
'argument' => (array) $matches[1],
'destination' => 'elements',
)
),
);
return $Block;
}
}
protected function blockQuoteContinue($Line, array $Block)
{
if (isset($Block['interrupted']))
{
return;
}
if ($Line['text'][0] === '>' and preg_match('/^>[ ]?+(.*+)/', $Line['text'], $matches))
{
$Block['element']['handler']['argument'] []= $matches[1];
return $Block;
}
if ( ! isset($Block['interrupted']))
{
$Block['element']['handler']['argument'] []= $Line['text'];
return $Block;
}
}
#
# Rule
protected function blockRule($Line)
{
$marker = $Line['text'][0];
if (substr_count($Line['text'], $marker) >= 3 and chop($Line['text'], " $marker") === '')
{
$Block = array(
'element' => array(
'name' => 'hr',
),
);
return $Block;
}
}
#
# Setext
protected function blockSetextHeader($Line, ?array $Block = null)
{
if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted']))
{
return;
}
if ($Line['indent'] < 4 and chop(chop($Line['text'], ' '), $Line['text'][0]) === '')
{
$Block['element']['name'] = $Line['text'][0] === '=' ? 'h1' : 'h2';
return $Block;
}
}
#
# Markup
protected function blockMarkup($Line)
{
if ($this->markupEscaped or $this->safeMode)
{
return;
}
if (preg_match('/^<[\/]?+(\w*)(?:[ ]*+'.$this->regexHtmlAttribute.')*+[ ]*+(\/)?>/', $Line['text'], $matches))
{
$element = strtolower($matches[1]);
if (in_array($element, $this->textLevelElements))
{
return;
}
$Block = array(
'name' => $matches[1],
'element' => array(
'rawHtml' => $Line['text'],
'autobreak' => true,
),
);
return $Block;
}
}
protected function blockMarkupContinue($Line, array $Block)
{
if (isset($Block['closed']) or isset($Block['interrupted']))
{
return;
}
$Block['element']['rawHtml'] .= "\n" . $Line['body'];
return $Block;
}
#
# Reference
protected function blockReference($Line)
{
if (strpos($Line['text'], ']') !== false
and preg_match('/^\[(.+?)\]:[ ]*+<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*+$/', $Line['text'], $matches)
) {
$id = strtolower($matches[1]);
$Data = array(
'url' => $matches[2],
'title' => isset($matches[3]) ? $matches[3] : null,
);
$this->DefinitionData['Reference'][$id] = $Data;
$Block = array(
'element' => array(),
);
return $Block;
}
}
#
# Table
protected function blockTable($Line, ?array $Block = null)
{
if ( ! isset($Block) or $Block['type'] !== 'Paragraph' or isset($Block['interrupted']))
{
return;
}
if (
strpos($Block['element']['handler']['argument'], '|') === false
and strpos($Line['text'], '|') === false
and strpos($Line['text'], ':') === false
or strpos($Block['element']['handler']['argument'], "\n") !== false
) {
return;
}
if (chop($Line['text'], ' -:|') !== '')
{
return;
}
$alignments = array();
$divider = $Line['text'];
$divider = trim($divider);
$divider = trim($divider, '|');
$dividerCells = explode('|', $divider);
foreach ($dividerCells as $dividerCell)
{
$dividerCell = trim($dividerCell);
if ($dividerCell === '')
{
return;
}
$alignment = null;
if ($dividerCell[0] === ':')
{
$alignment = 'left';
}
if (substr($dividerCell, - 1) === ':')
{
$alignment = $alignment === 'left' ? 'center' : 'right';
}
$alignments []= $alignment;
}
# ~
$HeaderElements = array();
$header = $Block['element']['handler']['argument'];
$header = trim($header);
$header = trim($header, '|');
$headerCells = explode('|', $header);
if (count($headerCells) !== count($alignments))
{
return;
}
foreach ($headerCells as $index => $headerCell)
{
$headerCell = trim($headerCell);
$HeaderElement = array(
'name' => 'th',
'handler' => array(
'function' => 'lineElements',
'argument' => $headerCell,
'destination' => 'elements',
)
);
if (isset($alignments[$index]))
{
$alignment = $alignments[$index];
$HeaderElement['attributes'] = array(
'style' => "text-align: $alignment;",
);
}
$HeaderElements []= $HeaderElement;
}
# ~
$Block = array(
'alignments' => $alignments,
'identified' => true,
'element' => array(
'name' => 'table',
'elements' => array(),
),
);
$Block['element']['elements'] []= array(
'name' => 'thead',
);
$Block['element']['elements'] []= array(
'name' => 'tbody',
'elements' => array(),
);
$Block['element']['elements'][0]['elements'] []= array(
'name' => 'tr',
'elements' => $HeaderElements,
);
return $Block;
}
protected function blockTableContinue($Line, array $Block)
{
if (isset($Block['interrupted']))
{
return;
}
if (count($Block['alignments']) === 1 or $Line['text'][0] === '|' or strpos($Line['text'], '|'))
{
$Elements = array();
$row = $Line['text'];
$row = trim($row);
$row = trim($row, '|');
preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]++`|`)++/', $row, $matches);
$cells = array_slice($matches[0], 0, count($Block['alignments']));
foreach ($cells as $index => $cell)
{
$cell = trim($cell);
$Element = array(
'name' => 'td',
'handler' => array(
'function' => 'lineElements',
'argument' => $cell,
'destination' => 'elements',
)
);
if (isset($Block['alignments'][$index]))
{
$Element['attributes'] = array(
'style' => 'text-align: ' . $Block['alignments'][$index] . ';',
);
}
$Elements []= $Element;
}
$Element = array(
'name' => 'tr',
'elements' => $Elements,
);
$Block['element']['elements'][1]['elements'] []= $Element;
return $Block;
}
}
#
# ~
#
protected function paragraph($Line)
{
return array(
'type' => 'Paragraph',
'element' => array(
'name' => 'p',
'handler' => array(
'function' => 'lineElements',
'argument' => $Line['text'],
'destination' => 'elements',
),
),
);
}
protected function paragraphContinue($Line, array $Block)
{
if (isset($Block['interrupted']))
{
return;
}
$Block['element']['handler']['argument'] .= "\n".$Line['text'];
return $Block;
}
#
# Inline Elements
#
protected $InlineTypes = array(
'!' => array('Image'),
'&' => array('SpecialCharacter'),
'*' => array('Emphasis'),
':' => array('Url'),
'<' => array('UrlTag', 'EmailTag', 'Markup'),
'[' => array('Link'),
'_' => array('Emphasis'),
'`' => array('Code'),
'~' => array('Strikethrough'),
'\\' => array('EscapeSequence'),
);
# ~
protected $inlineMarkerList = '!*_&[:<`~\\';
#
# ~
#
public function line($text, $nonNestables = array())
{
return $this->elements($this->lineElements($text, $nonNestables));
}
protected function lineElements($text, $nonNestables = array())
{
# standardize line breaks
$text = str_replace(array("\r\n", "\r"), "\n", $text);
$Elements = array();
$nonNestables = (empty($nonNestables)
? array()
: array_combine($nonNestables, $nonNestables)
);
# $excerpt is based on the first occurrence of a marker
while ($excerpt = strpbrk($text, $this->inlineMarkerList))
{
$marker = $excerpt[0];
$markerPosition = strlen($text) - strlen($excerpt);
$Excerpt = array('text' => $excerpt, 'context' => $text);
foreach ($this->InlineTypes[$marker] as $inlineType)
{
# check to see if the current inline type is nestable in the current context
if (isset($nonNestables[$inlineType]))
{
continue;
}
$Inline = $this->{"inline$inlineType"}($Excerpt);
if ( ! isset($Inline))
{
continue;
}
# 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;
}
# cause the new element to 'inherit' our non nestables
$Inline['element']['nonNestables'] = isset($Inline['element']['nonNestables'])
? array_merge($Inline['element']['nonNestables'], $nonNestables)
: $nonNestables
;
# the text that comes before the inline
$unmarkedText = substr($text, 0, $Inline['position']);
# compile the unmarked text
$InlineText = $this->inlineText($unmarkedText);
$Elements[] = $InlineText['element'];
# compile the inline
$Elements[] = $this->extractElement($Inline);
# remove the examined text
$text = substr($text, $Inline['position'] + $Inline['extent']);
continue 2;
}
# the marker does not belong to an inline
$unmarkedText = substr($text, 0, $markerPosition + 1);
$InlineText = $this->inlineText($unmarkedText);
$Elements[] = $InlineText['element'];
$text = substr($text, $markerPosition + 1);
}
$InlineText = $this->inlineText($text);
$Elements[] = $InlineText['element'];
foreach ($Elements as &$Element)
{
if ( ! isset($Element['autobreak']))
{
$Element['autobreak'] = false;
}
}
return $Elements;
}
#
# ~
#
protected function inlineText($text)
{
$Inline = array(
'extent' => strlen($text),
'element' => array(),
);
$Inline['element']['elements'] = self::pregReplaceElements(
$this->breaksEnabled ? '/[ ]*+\n/' : '/(?:[ ]*+\\\\|[ ]{2,}+)\n/',
array(
array('name' => 'br'),
array('text' => "\n"),
),
$text
);
return $Inline;
}
protected function inlineCode($Excerpt)
{
$marker = $Excerpt['text'][0];
if (preg_match('/^(['.$marker.']++)[ ]*+(.+?)[ ]*+(?<!['.$marker.'])\1(?!'.$marker.')/s', $Excerpt['text'], $matches))
{
$text = $matches[2];
$text = preg_replace('/[ ]*+\n/', ' ', $text);
return array(
'extent' => strlen($matches[0]),
'element' => array(
'name' => 'code',
'text' => $text,
),
);
}
}
protected function inlineEmailTag($Excerpt)
{
$hostnameLabel = '[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?';
$commonMarkEmail = '[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]++@'
. $hostnameLabel . '(?:\.' . $hostnameLabel . ')*';
if (strpos($Excerpt['text'], '>') !== false
and preg_match("/^<((mailto:)?$commonMarkEmail)>/i", $Excerpt['text'], $matches)
){
$url = $matches[1];
if ( ! isset($matches[2]))
{
$url = "mailto:$url";
}
return array(
'extent' => strlen($matches[0]),
'element' => array(
'name' => 'a',
'text' => $matches[1],
'attributes' => array(
'href' => $url,
),
),
);
}
}
protected function inlineEmphasis($Excerpt)
{
if ( ! isset($Excerpt['text'][1]))
{
return;
}
$marker = $Excerpt['text'][0];
if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
{
$emphasis = 'strong';
}
elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
{
$emphasis = 'em';
}
else
{
return;
}
return array(
'extent' => strlen($matches[0]),
'element' => array(
'name' => $emphasis,
'handler' => array(
'function' => 'lineElements',
'argument' => $matches[1],
'destination' => 'elements',
)
),
);
}
protected function inlineEscapeSequence($Excerpt)
{
if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters))
{
return array(
'element' => array('rawHtml' => $Excerpt['text'][1]),
'extent' => 2,
);
}
}
protected function inlineImage($Excerpt)
{
if ( ! isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[')
{
return;
}
$Excerpt['text']= substr($Excerpt['text'], 1);
$Link = $this->inlineLink($Excerpt);
if ($Link === null)
{
return;
}
$Inline = array(
'extent' => $Link['extent'] + 1,
'element' => array(
'name' => 'img',
'attributes' => array(
'src' => $Link['element']['attributes']['href'],
'alt' => $Link['element']['handler']['argument'],
),
'autobreak' => true,
),
);
$Inline['element']['attributes'] += $Link['element']['attributes'];
unset($Inline['element']['attributes']['href']);
return $Inline;
}
protected function inlineLink($Excerpt)
{
$Element = array(
'name' => 'a',
'handler' => array(
'function' => 'lineElements',
'argument' => null,
'destination' => 'elements',
),
'nonNestables' => array('Url', 'Link'),
'attributes' => array(
'href' => null,
'title' => null,
),
);
$extent = 0;
$remainder = $Excerpt['text'];
if (preg_match('/\[((?:[^][]++|(?R))*+)\]/', $remainder, $matches))
{
$Element['handler']['argument'] = $matches[1];
$extent += strlen($matches[0]);
$remainder = substr($remainder, $extent);
}
else
{
return;
}
if (preg_match('/^[(]\s*+((?:[^ ()]++|[(][^ )]+[)])++)(?:[ ]+("[^"]*+"|\'[^\']*+\'))?\s*+[)]/', $remainder, $matches))
{
$Element['attributes']['href'] = $matches[1];
if (isset($matches[2]))
{
$Element['attributes']['title'] = substr($matches[2], 1, - 1);
}
$extent += strlen($matches[0]);
}
else
{
if (preg_match('/^\s*\[(.*?)\]/', $remainder, $matches))
{
$definition = strlen($matches[1]) ? $matches[1] : $Element['handler']['argument'];
$definition = strtolower($definition);
$extent += strlen($matches[0]);
}
else
{
$definition = strtolower($Element['handler']['argument']);
}
if ( ! isset($this->DefinitionData['Reference'][$definition]))
{
return;
}
$Definition = $this->DefinitionData['Reference'][$definition];
$Element['attributes']['href'] = $Definition['url'];
$Element['attributes']['title'] = $Definition['title'];
}
return array(
'extent' => $extent,
'element' => $Element,
);
}
protected function inlineMarkup($Excerpt)
{
if ($this->markupEscaped or $this->safeMode or strpos($Excerpt['text'], '>') === false)
{
return;
}
if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w[\w-]*+[ ]*+>/s', $Excerpt['text'], $matches))
{
return array(
'element' => array('rawHtml' => $matches[0]),
'extent' => strlen($matches[0]),
);
}
if ($Excerpt['text'][1] === '!' and preg_match('/^<!---?[^>-](?:-?+[^-])*-->/s', $Excerpt['text'], $matches))
{
return array(
'element' => array('rawHtml' => $matches[0]),
'extent' => strlen($matches[0]),
);
}
if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*+(?:[ ]*+'.$this->regexHtmlAttribute.')*+[ ]*+\/?>/s', $Excerpt['text'], $matches))
{
return array(
'element' => array('rawHtml' => $matches[0]),
'extent' => strlen($matches[0]),
);
}
}
protected function inlineSpecialCharacter($Excerpt)
{
if (substr($Excerpt['text'], 1, 1) !== ' ' and strpos($Excerpt['text'], ';') !== false
and preg_match('/^&(#?+[0-9a-zA-Z]++);/', $Excerpt['text'], $matches)
) {
return array(
'element' => array('rawHtml' => '&' . $matches[1] . ';'),
'extent' => strlen($matches[0]),
);
}
}
protected function inlineStrikethrough($Excerpt)
{
if ( ! isset($Excerpt['text'][1]))
{
return;
}
if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches))
{
return array(
'extent' => strlen($matches[0]),
'element' => array(
'name' => 'del',
'handler' => array(
'function' => 'lineElements',
'argument' => $matches[1],
'destination' => 'elements',
)
),
);
}
}
protected function inlineUrl($Excerpt)
{
if ($this->urlsLinked !== true or ! isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/')
{
return;
}
if (strpos($Excerpt['context'], 'http') !== false
and preg_match('/\bhttps?+:[\/]{2}[^\s<]+\b\/*+/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)
) {
$url = $matches[0][0];
$Inline = array(
'extent' => strlen($matches[0][0]),
'position' => $matches[0][1],
'element' => array(
'name' => 'a',
'text' => $url,
'attributes' => array(
'href' => $url,
),
),
);
return $Inline;
}
}
protected function inlineUrlTag($Excerpt)
{
if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w++:\/{2}[^ >]++)>/i', $Excerpt['text'], $matches))
{
$url = $matches[1];
return array(
'extent' => strlen($matches[0]),
'element' => array(
'name' => 'a',
'text' => $url,
'attributes' => array(
'href' => $url,
),
),
);
}
}
# ~
protected function unmarkedText($text)
{
$Inline = $this->inlineText($text);
return $this->element($Inline['element']);
}
#
# Handlers
#
protected function handle(array $Element)
{
if (isset($Element['handler']))
{
if (!isset($Element['nonNestables']))
{
$Element['nonNestables'] = array();
}
if (is_string($Element['handler']))
{
$function = $Element['handler'];
$argument = $Element['text'];
unset($Element['text']);
$destination = 'rawHtml';
}
else
{
$function = $Element['handler']['function'];
$argument = $Element['handler']['argument'];
$destination = $Element['handler']['destination'];
}
$Element[$destination] = $this->{$function}($argument, $Element['nonNestables']);
if ($destination === 'handler')
{
$Element = $this->handle($Element);
}
unset($Element['handler']);
}
return $Element;
}
protected function handleElementRecursive(array $Element)
{
return $this->elementApplyRecursive(array($this, 'handle'), $Element);
}
protected function handleElementsRecursive(array $Elements)
{
return $this->elementsApplyRecursive(array($this, 'handle'), $Elements);
}
protected function elementApplyRecursive($closure, array $Element)
{
$Element = call_user_func($closure, $Element);
if (isset($Element['elements']))
{
$Element['elements'] = $this->elementsApplyRecursive($closure, $Element['elements']);
}
elseif (isset($Element['element']))
{
$Element['element'] = $this->elementApplyRecursive($closure, $Element['element']);
}
return $Element;
}
protected function elementApplyRecursiveDepthFirst($closure, array $Element)
{
if (isset($Element['elements']))
{
$Element['elements'] = $this->elementsApplyRecursiveDepthFirst($closure, $Element['elements']);
}
elseif (isset($Element['element']))
{
$Element['element'] = $this->elementsApplyRecursiveDepthFirst($closure, $Element['element']);
}
$Element = call_user_func($closure, $Element);
return $Element;
}
protected function elementsApplyRecursive($closure, array $Elements)
{
foreach ($Elements as &$Element)
{
$Element = $this->elementApplyRecursive($closure, $Element);
}
return $Elements;
}
protected function elementsApplyRecursiveDepthFirst($closure, array $Elements)
{
foreach ($Elements as &$Element)
{
$Element = $this->elementApplyRecursiveDepthFirst($closure, $Element);
}
return $Elements;
}
protected function element(array $Element)
{
if ($this->safeMode)
{
$Element = $this->sanitiseElement($Element);
}
# identity map if element has no handler
$Element = $this->handle($Element);
$hasName = isset($Element['name']);
$markup = '';
if ($hasName)
{
$markup .= '<' . $Element['name'];
if (isset($Element['attributes']))
{
foreach ($Element['attributes'] as $name => $value)
{
if ($value === null)
{
continue;
}
$markup .= " $name=\"".self::escape($value).'"';
}
}
}
$permitRawHtml = false;
if (isset($Element['text']))
{
$text = $Element['text'];
}
// very strongly consider an alternative if you're writing an
// extension
elseif (isset($Element['rawHtml']))
{
$text = $Element['rawHtml'];
$allowRawHtmlInSafeMode = isset($Element['allowRawHtmlInSafeMode']) && $Element['allowRawHtmlInSafeMode'];
$permitRawHtml = !$this->safeMode || $allowRawHtmlInSafeMode;
}
$hasContent = isset($text) || isset($Element['element']) || isset($Element['elements']);
if ($hasContent)
{
$markup .= $hasName ? '>' : '';
if (isset($Element['elements']))
{
$markup .= $this->elements($Element['elements']);
}
elseif (isset($Element['element']))
{
$markup .= $this->element($Element['element']);
}
else
{
if (!$permitRawHtml)
{
$markup .= self::escape($text, true);
}
else
{
$markup .= $text;
}
}
$markup .= $hasName ? '</' . $Element['name'] . '>' : '';
}
elseif ($hasName)
{
$markup .= ' />';
}
return $markup;
}
protected function elements(array $Elements)
{
$markup = '';
$autoBreak = true;
foreach ($Elements as $Element)
{
if (empty($Element))
{
continue;
}
$autoBreakNext = (isset($Element['autobreak'])
? $Element['autobreak'] : isset($Element['name'])
);
// (autobreak === false) covers both sides of an element
$autoBreak = !$autoBreak ? $autoBreak : $autoBreakNext;
$markup .= ($autoBreak ? "\n" : '') . $this->element($Element);
$autoBreak = $autoBreakNext;
}
$markup .= $autoBreak ? "\n" : '';
return $markup;
}
# ~
protected function li($lines)
{
$Elements = $this->linesElements($lines);
if ( ! in_array('', $lines)
and isset($Elements[0]) and isset($Elements[0]['name'])
and $Elements[0]['name'] === 'p'
) {
unset($Elements[0]['name']);
}
return $Elements;
}
#
# AST Convenience
#
/**
* Replace occurrences $regexp with $Elements in $text. Return an array of
* elements representing the replacement.
*/
protected static function pregReplaceElements($regexp, $Elements, $text)
{
$newElements = array();
while (preg_match($regexp, $text, $matches, PREG_OFFSET_CAPTURE))
{
$offset = $matches[0][1];
$before = substr($text, 0, $offset);
$after = substr($text, $offset + strlen($matches[0][0]));
$newElements[] = array('text' => $before);
foreach ($Elements as $Element)
{
$newElements[] = $Element;
}
$text = $after;
}
$newElements[] = array('text' => $text);
return $newElements;
}
#
# Deprecated Methods
#
/**
* @deprecated use text() instead
*/
function parse($text)
{
$markup = $this->text($text);
return $markup;
}
protected function sanitiseElement(array $Element)
{
static $goodAttribute = '/^[a-zA-Z0-9][a-zA-Z0-9-_]*+$/';
static $safeUrlNameToAtt = array(
'a' => 'href',
'img' => 'src',
);
if ( ! isset($Element['name']))
{
unset($Element['attributes']);
return $Element;
}
if (isset($safeUrlNameToAtt[$Element['name']]))
{
$Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]);
}
if ( ! empty($Element['attributes']))
{
foreach ($Element['attributes'] as $att => $val)
{
# filter out badly parsed attribute
if ( ! preg_match($goodAttribute, $att))
{
unset($Element['attributes'][$att]);
}
# dump onevent attribute
elseif (self::striAtStart($att, 'on'))
{
unset($Element['attributes'][$att]);
}
}
}
return $Element;
}
protected function filterUnsafeUrlInAttribute(array $Element, $attribute)
{
foreach ($this->safeLinksWhitelist as $scheme)
{
if (self::striAtStart($Element['attributes'][$attribute], $scheme))
{
return $Element;
}
}
$Element['attributes'][$attribute] = str_replace(':', '%3A', $Element['attributes'][$attribute]);
return $Element;
}
#
# Static Methods
#
protected static function escape($text, $allowQuotes = false)
{
return htmlspecialchars($text, $allowQuotes ? ENT_NOQUOTES : ENT_QUOTES, 'UTF-8');
}
protected static function striAtStart($string, $needle)
{
$len = strlen($needle);
if ($len > strlen($string))
{
return false;
}
else
{
return strtolower(substr($string, 0, $len)) === strtolower($needle);
}
}
static function instance($name = 'default')
{
if (isset(self::$instances[$name]))
{
return self::$instances[$name];
}
$instance = new static();
self::$instances[$name] = $instance;
return $instance;
}
private static $instances = array();
#
# Fields
#
protected $DefinitionData;
#
# Read-Only
protected $specialCharacters = array(
'\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', '~'
);
protected $StrongRegex = array(
'*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*+[*])+?)[*]{2}(?![*])/s',
'_' => '/^__((?:\\\\_|[^_]|_[^_]*+_)+?)__(?!_)/us',
);
protected $EmRegex = array(
'*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s',
'_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us',
);
protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*+(?:\s*+=\s*+(?:[^"\'=<>`\s]+|"[^"]*+"|\'[^\']*+\'))?+';
protected $voidElements = array(
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source',
);
protected $textLevelElements = array(
'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont',
'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing',
'i', 'rp', 'del', 'code', 'strike', 'marquee',
'q', 'rt', 'ins', 'font', 'strong',
's', 'tt', 'kbd', 'mark',
'u', 'xm', 'sub', 'nobr',
'sup', 'ruby',
'var', 'span',
'wbr', 'time',
);
}
================================================
FILE: composer.json
================================================
{
"name": "erusev/parsedown",
"description": "Parser for Markdown.",
"keywords": ["markdown", "parser"],
"homepage": "http://parsedown.org",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
"homepage": "http://erusev.com"
}
],
"require": {
"php": ">=7.2",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^8.5.52|^9.6.33"
},
"autoload": {
"psr-0": { "Parsedown": "" }
},
"autoload-dev": {
"psr-0": {
"TestParsedown": "test/",
"ParsedownTest": "test/",
"CommonMarkTest": "test/",
"CommonMarkTestWeak": "test/"
}
}
}
================================================
FILE: phpunit.xml.dist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="Parsedown">
<file>test/ParsedownTest.php</file>
</testsuite>
</testsuites>
</phpunit>
================================================
FILE: readme.md
================================================
# Parsedown
[](https://packagist.org/packages/erusev/parsedown)
[](https://packagist.org/packages/erusev/parsedown)
[](https://packagist.org/packages/erusev/parsedown)
Better Markdown Parser in PHP — <a href="https://parsedown.org/demo">demo</a>
## Features
- One file
- No dependencies
- [Super fast](http://parsedown.org/speed)
- Extensible
- [GitHub flavored](https://github.github.com/gfm)
- [Tested](http://parsedown.org/tests/) in PHP 7.1+
- [Markdown Extra extension](https://github.com/erusev/parsedown-extra)
## Installation
Install the [composer package]:
```sh
composer require erusev/parsedown
```
Or download the [latest release] and include `Parsedown.php`
[composer package]: https://packagist.org/packages/erusev/parsedown "The Parsedown package on packagist.org"
[latest release]: https://github.com/erusev/parsedown/releases/latest "The latest release of Parsedown"
## Example
```php
$Parsedown = new Parsedown();
echo $Parsedown->text('Hello _Parsedown_!'); # prints: <p>Hello <em>Parsedown</em>!</p>
```
You can also parse inline markdown only:
```php
echo $Parsedown->line('Hello _Parsedown_!'); # prints: Hello <em>Parsedown</em>!
```
More examples in [the wiki](https://github.com/erusev/parsedown/wiki/) and in [this video tutorial](http://youtu.be/wYZBY8DEikI).
## Security
Parsedown is capable of escaping user-input within the HTML that it generates. Additionally Parsedown will apply sanitisation to additional scripting vectors (such as scripting link destinations) that are introduced by the markdown syntax itself.
To tell Parsedown that it is processing untrusted user-input, use the following:
```php
$Parsedown->setSafeMode(true);
```
If instead, you wish to allow HTML within untrusted user-input, but still want output to be free from XSS it is recommended that you make use of a HTML sanitiser that allows HTML tags to be whitelisted, like [HTML Purifier](http://htmlpurifier.org/).
In both cases you should strongly consider employing defence-in-depth measures, like [deploying a Content-Security-Policy](https://scotthelme.co.uk/content-security-policy-an-introduction/) (a browser security feature) so that your page is likely to be safe even if an attacker finds a vulnerability in one of the first lines of defence above.
Safe mode does not necessarily yield safe results when using extensions to Parsedown. Extensions should be evaluated on their own to determine their specific safety against XSS.
## Escaping HTML
> WARNING: This method is not safe from XSS!
If you wish to escape HTML in trusted input, you can use the following:
```php
$Parsedown->setMarkupEscaped(true);
```
Beware that this still allows users to insert unsafe scripting vectors, ex: `[xss](javascript:alert%281%29)`.
## Questions
**How does Parsedown work?**
It tries to read Markdown like a human. First, it looks at the lines. It’s interested in how the lines start. This helps it recognise blocks. It knows, for example, that if a line starts with a `-` then perhaps it belongs to a list. Once it recognises the blocks, it continues to the content. As it reads, it watches out for special characters. This helps it recognise inline elements (or inlines).
We call this approach "line based". We believe that Parsedown is the first Markdown parser to use it. Since the release of Parsedown, other developers have used the same approach to develop other Markdown parsers in PHP and in other languages.
**Is it compliant with CommonMark?**
It passes most of the CommonMark tests. Most of the tests that don't pass deal with cases that are quite uncommon. Still, as CommonMark matures, compliance should improve.
**Who uses it?**
[Laravel Framework](https://laravel.com/), [Bolt CMS](http://bolt.cm/), [Grav CMS](http://getgrav.org/), [Herbie CMS](http://www.getherbie.org/), [Kirby CMS](http://getkirby.com/), [October CMS](http://octobercms.com/), [Pico CMS](http://picocms.org), [Statamic CMS](http://www.statamic.com/), [phpDocumentor](http://www.phpdoc.org/), [RaspberryPi.org](http://www.raspberrypi.org/), [Symfony Demo](https://github.com/symfony/demo) and [more](https://packagist.org/packages/erusev/parsedown/dependents).
**How can I help?**
Use it, star it, share it and if you feel generous, [sponsor me](https://github.com/sponsors/erusev).
**What else should I know?**
I also make [Nota](https://nota.md/) — a notes app designed for local Markdown files.
================================================
FILE: test/CommonMarkTestStrict.php
================================================
<?php
use PHPUnit\Framework\TestCase;
/**
* Test Parsedown against the CommonMark spec
*
* @link http://commonmark.org/ CommonMark
*/
class CommonMarkTestStrict extends TestCase
{
const SPEC_URL = 'https://raw.githubusercontent.com/jgm/CommonMark/master/spec.txt';
protected $parsedown;
protected function setUp() : void
{
$this->parsedown = new TestParsedown();
$this->parsedown->setUrlsLinked(false);
}
/**
* @dataProvider data
* @param $id
* @param $section
* @param $markdown
* @param $expectedHtml
*/
public function testExample($id, $section, $markdown, $expectedHtml)
{
$actualHtml = $this->parsedown->text($markdown);
$this->assertEquals($expectedHtml, $actualHtml);
}
/**
* @return array
*/
public function data()
{
$spec = file_get_contents(self::SPEC_URL);
if ($spec === false) {
$this->fail('Unable to load CommonMark spec from ' . self::SPEC_URL);
}
$spec = str_replace("\r\n", "\n", $spec);
$spec = strstr($spec, '<!-- END TESTS -->', true);
$matches = array();
preg_match_all('/^`{32} example\n((?s).*?)\n\.\n(?:|((?s).*?)\n)`{32}$|^#{1,6} *(.*?)$/m', $spec, $matches, PREG_SET_ORDER);
$data = array();
$currentId = 0;
$currentSection = '';
foreach ($matches as $match) {
if (isset($match[3])) {
$currentSection = $match[3];
} else {
$currentId++;
$markdown = str_replace('→', "\t", $match[1]);
$expectedHtml = isset($match[2]) ? str_replace('→', "\t", $match[2]) : '';
$data[$currentId] = array(
'id' => $currentId,
'section' => $currentSection,
'markdown' => $markdown,
'expectedHtml' => $expectedHtml
);
}
}
return $data;
}
}
================================================
FILE: test/CommonMarkTestWeak.php
================================================
<?php
require_once(__DIR__ . '/CommonMarkTestStrict.php');
/**
* Test Parsedown against the CommonMark spec, but less aggressive
*
* The resulting HTML markup is cleaned up before comparison, so examples
* which would normally fail due to actually invisible differences (e.g.
* superfluous whitespaces), don't fail. However, cleanup relies on block
* element detection. The detection doesn't work correctly when a element's
* `display` CSS property is manipulated. According to that this test is only
* a interim solution on Parsedown's way to full CommonMark compatibility.
*
* @link http://commonmark.org/ CommonMark
*/
class CommonMarkTestWeak extends CommonMarkTestStrict
{
protected $textLevelElementRegex;
protected function setUp() : void
{
parent::setUp();
$textLevelElements = $this->parsedown->getTextLevelElements();
array_walk($textLevelElements, function (&$element) {
$element = preg_quote($element, '/');
});
$this->textLevelElementRegex = '\b(?:' . implode('|', $textLevelElements) . ')\b';
}
/**
* @dataProvider data
* @param $id
* @param $section
* @param $markdown
* @param $expectedHtml
*/
public function testExample($id, $section, $markdown, $expectedHtml)
{
$expectedHtml = $this->cleanupHtml($expectedHtml);
$actualHtml = $this->parsedown->text($markdown);
$actualHtml = $this->cleanupHtml($actualHtml);
$this->assertEquals($expectedHtml, $actualHtml);
}
protected function cleanupHtml($markup)
{
// invisible whitespaces at the beginning and end of block elements
// however, whitespaces at the beginning of <pre> elements do matter
$markup = preg_replace(
array(
'/(<(?!(?:' . $this->textLevelElementRegex . '|\bpre\b))\w+\b[^>]*>(?:<' . $this->textLevelElementRegex . '[^>]*>)*)\s+/s',
'/\s+((?:<\/' . $this->textLevelElementRegex . '>)*<\/(?!' . $this->textLevelElementRegex . ')\w+\b>)/s'
),
'$1',
$markup
);
return $markup;
}
}
================================================
FILE: test/ParsedownTest.php
================================================
<?php
require 'SampleExtensions.php';
use PHPUnit\Framework\TestCase;
class ParsedownTest extends TestCase
{
final function __construct($name = null, array $data = array(), $dataName = '')
{
$this->dirs = $this->initDirs();
$this->Parsedown = $this->initParsedown();
parent::__construct($name, $data, $dataName);
}
private $dirs;
protected $Parsedown;
/**
* @return array
*/
protected function initDirs()
{
$dirs []= dirname(__FILE__).'/data/';
return $dirs;
}
/**
* @return Parsedown
*/
protected function initParsedown()
{
$Parsedown = new TestParsedown();
return $Parsedown;
}
/**
* @dataProvider data
* @param $test
* @param $dir
*/
function test_($test, $dir)
{
$markdown = file_get_contents($dir . $test . '.md');
$expectedMarkup = file_get_contents($dir . $test . '.html');
$expectedMarkup = str_replace("\r\n", "\n", $expectedMarkup);
$expectedMarkup = str_replace("\r", "\n", $expectedMarkup);
$this->Parsedown->setSafeMode(substr($test, 0, 3) === 'xss');
$this->Parsedown->setStrictMode(substr($test, 0, 6) === 'strict');
$actualMarkup = $this->Parsedown->text($markdown);
$this->assertEquals($expectedMarkup, $actualMarkup);
}
function testRawHtml()
{
$markdown = "```php\nfoobar\n```";
$expectedMarkup = '<pre><code class="language-php"><p>foobar</p></code></pre>';
$expectedSafeMarkup = '<pre><code class="language-php"><p>foobar</p></code></pre>';
$unsafeExtension = new UnsafeExtension;
$actualMarkup = $unsafeExtension->text($markdown);
$this->assertEquals($expectedMarkup, $actualMarkup);
$unsafeExtension->setSafeMode(true);
$actualSafeMarkup = $unsafeExtension->text($markdown);
$this->assertEquals($expectedSafeMarkup, $actualSafeMarkup);
}
function testTrustDelegatedRawHtml()
{
$markdown = "```php\nfoobar\n```";
$expectedMarkup = '<pre><code class="language-php"><p>foobar</p></code></pre>';
$expectedSafeMarkup = $expectedMarkup;
$unsafeExtension = new TrustDelegatedExtension;
$actualMarkup = $unsafeExtension->text($markdown);
$this->assertEquals($expectedMarkup, $actualMarkup);
$unsafeExtension->setSafeMode(true);
$actualSafeMarkup = $unsafeExtension->text($markdown);
$this->assertEquals($expectedSafeMarkup, $actualSafeMarkup);
}
function data()
{
$data = array();
foreach ($this->dirs as $dir)
{
$Folder = new DirectoryIterator($dir);
foreach ($Folder as $File)
{
/** @var $File DirectoryIterator */
if ( ! $File->isFile())
{
continue;
}
$filename = $File->getFilename();
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if ($extension !== 'md')
{
continue;
}
$basename = $File->getBasename('.md');
if (file_exists($dir . $basename . '.html'))
{
$data []= array($basename, $dir);
}
}
}
return $data;
}
public function test_no_markup()
{
$markdownWithHtml = <<<MARKDOWN_WITH_MARKUP
<div>_content_</div>
sparse:
<div>
<div class="inner">
_content_
</div>
</div>
paragraph
<style type="text/css">
p {
color: red;
}
</style>
comment
<!-- html comment -->
MARKDOWN_WITH_MARKUP;
$expectedHtml = <<<EXPECTED_HTML
<p><div><em>content</em></div></p>
<p>sparse:</p>
<p><div>
<div class="inner">
<em>content</em>
</div>
</div></p>
<p>paragraph</p>
<p><style type="text/css">
p {
color: red;
}
</style></p>
<p>comment</p>
<p><!-- html comment --></p>
EXPECTED_HTML;
$parsedownWithNoMarkup = new TestParsedown();
$parsedownWithNoMarkup->setMarkupEscaped(true);
$this->assertEquals($expectedHtml, $parsedownWithNoMarkup->text($markdownWithHtml));
}
public function testLateStaticBinding()
{
$parsedown = Parsedown::instance();
$this->assertInstanceOf('Parsedown', $parsedown);
// After instance is already called on Parsedown
// subsequent calls with the same arguments return the same instance
$sameParsedown = TestParsedown::instance();
$this->assertInstanceOf('Parsedown', $sameParsedown);
$this->assertSame($parsedown, $sameParsedown);
$testParsedown = TestParsedown::instance('test late static binding');
$this->assertInstanceOf('TestParsedown', $testParsedown);
$sameInstanceAgain = TestParsedown::instance('test late static binding');
$this->assertSame($testParsedown, $sameInstanceAgain);
}
}
================================================
FILE: test/SampleExtensions.php
================================================
<?php
class UnsafeExtension extends Parsedown
{
protected function blockFencedCodeComplete($Block)
{
$text = $Block['element']['element']['text'];
unset($Block['element']['element']['text']);
// WARNING: There is almost always a better way of doing things!
//
// This example is one of them, unsafe behaviour is NOT needed here.
// Only use this if you trust the input and have no idea what
// the output HTML will look like (e.g. using an external parser).
$Block['element']['element']['rawHtml'] = "<p>$text</p>";
return $Block;
}
}
class TrustDelegatedExtension extends Parsedown
{
protected function blockFencedCodeComplete($Block)
{
$text = $Block['element']['element']['text'];
unset($Block['element']['element']['text']);
// WARNING: There is almost always a better way of doing things!
//
// This behaviour is NOT needed in the demonstrated case.
// Only use this if you are sure that the result being added into
// rawHtml is safe.
// (e.g. using an external parser with escaping capabilities).
$Block['element']['element']['rawHtml'] = "<p>$text</p>";
$Block['element']['element']['allowRawHtmlInSafeMode'] = true;
return $Block;
}
}
================================================
FILE: test/TestParsedown.php
================================================
<?php
class TestParsedown extends Parsedown
{
public function getTextLevelElements()
{
return $this->textLevelElements;
}
}
================================================
FILE: test/data/aesthetic_table.html
================================================
<table>
<thead>
<tr>
<th>header 1</th>
<th>header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>cell 1.1</td>
<td>cell 1.2</td>
</tr>
<tr>
<td>cell 2.1</td>
<td>cell 2.2</td>
</tr>
</tbody>
</table>
================================================
FILE: test/data/aligned_table.html
================================================
<table>
<thead>
<tr>
<th style="text-align: left;">header 1</th>
<th style="text-align: center;">header 2</th>
<th style="text-align: right;">header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">cell 1.1</td>
<td style="text-align: center;">cell 1.2</td>
<td style="text-align: right;">cell 1.3</td>
</tr>
<tr>
<td style="text-align: left;">cell 2.1</td>
<td style="text-align: center;">cell 2.2</td>
<td style="text-align: right;">cell 2.3</td>
</tr>
</tbody>
</table>
================================================
FILE: test/data/atx_heading.html
================================================
<h1>h1</h1>
<h2>h2</h2>
<h3>h3</h3>
<h4>h4</h4>
<h5>h5</h5>
<h6>h6</h6>
<p>####### not a heading</p>
<h1>closed h1</h1>
<h1></h1>
<h2></h2>
<h1># of levels</h1>
<h1># of levels #</h1>
<h1>heading</h1>
================================================
FILE: test/data/automatic_link.html
================================================
<p><a href="http://example.com">http://example.com</a></p>
================================================
FILE: test/data/block-level_html.html
================================================
<div>_content_</div>
<p>paragraph</p>
<div>
<div class="inner">
_content_
</div>
</div>
<style type="text/css">
p {color: #789;}
</style>
<div>
<a href="/">home</a></div>
================================================
FILE: test/data/code_block.html
================================================
<pre><code><?php
$message = 'Hello World!';
echo $message;</code></pre>
<hr />
<pre><code>> not a quote
- not a list item
[not a reference]: http://foo.com</code></pre>
<hr />
<pre><code>foo
bar</code></pre>
================================================
FILE: test/data/code_span.html
================================================
<p>a <code>code span</code></p>
<p><code>this is also a codespan</code> trailing text</p>
<p><code>and look at this one!</code></p>
<p>single backtick in a code span: <code>`</code></p>
<p>backtick-delimited string in a code span: <code>`foo`</code></p>
<p><code>sth `` sth</code></p>
================================================
FILE: test/data/compound_blockquote.html
================================================
<blockquote>
<h2>header</h2>
<p>paragraph</p>
<ul>
<li>li</li>
</ul>
<hr />
<p>paragraph</p>
</blockquote>
================================================
FILE: test/data/compound_emphasis.html
================================================
<p><em><code>code</code></em> <strong><code>code</code></strong></p>
<p><em><code>code</code><strong><code>code</code></strong><code>code</code></em></p>
================================================
FILE: test/data/compound_list.html
================================================
<ul>
<li>
<p>paragraph</p>
<p>paragraph</p>
</li>
<li>
<p>paragraph</p>
<blockquote>
<p>quote</p>
</blockquote>
</li>
</ul>
================================================
FILE: test/data/deeply_nested_list.html
================================================
<ul>
<li>li<ul>
<li>li<ul>
<li>li</li>
<li>li</li>
</ul>
</li>
<li>li</li>
</ul>
</li>
<li>li</li>
</ul>
<hr />
<ul>
<li>level 1<ul>
<li>level 2<ul>
<li>level 3<ul>
<li>level 4<ul>
<li>level 5</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<hr />
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
<li>e</li>
<li>f</li>
<li>g</li>
<li>h</li>
<li>i</li>
</ul>
================================================
FILE: test/data/em_strong.html
================================================
<p><strong><em>em strong</em></strong></p>
<p><strong><em>em strong</em> strong</strong></p>
<p><strong>strong <em>em strong</em></strong></p>
<p><strong>strong <em>em strong</em> strong</strong></p>
<p><strong><em>em strong</em></strong></p>
<p><strong><em>em strong</em> strong</strong></p>
<p><strong>strong <em>em strong</em></strong></p>
<p><strong>strong <em>em strong</em> strong</strong></p>
================================================
FILE: test/data/email.html
================================================
<p>my email is <a href="mailto:me@example.com">me@example.com</a></p>
<p>html tags shouldn't start an email autolink <strong>first.last@example.com</strong></p>
================================================
FILE: test/data/emphasis.html
================================================
<p><em>underscore</em>, <em>asterisk</em>, <em>one two</em>, <em>three four</em>, <em>a</em>, <em>b</em></p>
<p><strong>strong</strong> and <em>em</em> and <strong>strong</strong> and <em>em</em></p>
<p><em>line
line
line</em></p>
<p>this_is_not_an_emphasis</p>
<p>an empty emphasis __ ** is not an emphasis</p>
<p>*mixed *<em>double and</em> single asterisk** spans</p>
================================================
FILE: test/data/escaping.html
================================================
<p>escaped *emphasis*.</p>
<p><code>escaped \*emphasis\* in a code span</code></p>
<pre><code>escaped \*emphasis\* in a code block</code></pre>
<p>\ ` * _ { } [ ] ( ) > # + - . !</p>
<p><em>one_two</em> <strong>one_two</strong></p>
<p><em>one*two</em> <strong>one*two</strong></p>
================================================
FILE: test/data/fenced_code_block.html
================================================
<pre><code><?php
$message = 'fenced code block';
echo $message;</code></pre>
<pre><code>tilde</code></pre>
<pre><code class="language-php">echo 'language identifier';</code></pre>
<pre><code class="language-c#">echo 'language identifier with non words';</code></pre>
<pre><code class="language-html+php"><?php
echo "Hello World";
?>
<a href="http://auraphp.com" >Aura Project</a></code></pre>
<pre><code>the following isn't quite enough to close
```
still a fenced code block</code></pre>
<pre><code>foo
bar</code></pre>
<pre><code class="language-php"><?php
echo "Hello World";</code></pre>
================================================
FILE: test/data/horizontal_rule.html
================================================
<hr />
<hr />
<hr />
<hr />
<hr />
================================================
FILE: test/data/html_comment.html
================================================
<!-- single line -->
<p>paragraph</p>
<!--
multiline -->
<p>paragraph</p>
<!-- sss -->abc
<ul>
<li>abcd</li>
<li>bbbb</li>
<li>cccc</li>
</ul>
================================================
FILE: test/data/html_entity.html
================================================
<p>& © {</p>
================================================
FILE: test/data/image_reference.html
================================================
<p><img src="/md.png" alt="Markdown Logo" /></p>
<p>![missing reference]</p>
================================================
FILE: test/data/image_title.html
================================================
<p><img src="/md.png" alt="alt" title="title" /></p>
<p><img src="/md.png" alt="blank title" title="" /></p>
================================================
FILE: test/data/implicit_reference.html
================================================
<p>an <a href="http://example.com">implicit</a> reference link</p>
<p>an <a href="http://example.com">implicit</a> reference link with an empty link definition</p>
<p>an <a href="http://example.com">implicit</a> reference link followed by <a href="http://cnn.com">another</a></p>
<p>an <a href="http://example.com" title="Example">explicit</a> reference link with a title</p>
================================================
FILE: test/data/inline_link.html
================================================
<p><a href="http://example.com">link</a></p>
<p><a href="/url-(parentheses)">link</a> with parentheses in URL </p>
<p>(<a href="/index.php">link</a>) in parentheses</p>
<p><a href="http://example.com"><code>link</code></a></p>
<p><a href="http://example.com"><img src="http://parsedown.org/md.png" alt="MD Logo" /></a></p>
<p><a href="http://example.com"><img src="http://parsedown.org/md.png" alt="MD Logo" /> and text</a></p>
<p><a href="http://example.com"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAUCAYAAADskT9PAAAKQWlDQ1BJQ0MgUHJvZmlsZQAASA2dlndUU9kWh8+9N73QEiIgJfQaegkg0jtIFQRRiUmAUAKGhCZ2RAVGFBEpVmRUwAFHhyJjRRQLg4Ji1wnyEFDGwVFEReXdjGsJ7601896a/cdZ39nnt9fZZ+9917oAUPyCBMJ0WAGANKFYFO7rwVwSE8vE9wIYEAEOWAHA4WZmBEf4RALU/L09mZmoSMaz9u4ugGS72yy/UCZz1v9/kSI3QyQGAApF1TY8fiYX5QKUU7PFGTL/BMr0lSkyhjEyFqEJoqwi48SvbPan5iu7yZiXJuShGlnOGbw0noy7UN6aJeGjjAShXJgl4GejfAdlvVRJmgDl9yjT0/icTAAwFJlfzOcmoWyJMkUUGe6J8gIACJTEObxyDov5OWieAHimZ+SKBIlJYqYR15hp5ejIZvrxs1P5YjErlMNN4Yh4TM/0tAyOMBeAr2+WRQElWW2ZaJHtrRzt7VnW5mj5v9nfHn5T/T3IevtV8Sbsz55BjJ5Z32zsrC+9FgD2JFqbHbO+lVUAtG0GQOXhrE/vIADyBQC03pzzHoZsXpLE4gwnC4vs7GxzAZ9rLivoN/ufgm/Kv4Y595nL7vtWO6YXP4EjSRUzZUXlpqemS0TMzAwOl89k/fcQ/+PAOWnNycMsnJ/AF/GF6FVR6JQJhIlou4U8gViQLmQKhH/V4X8YNicHGX6daxRodV8AfYU5ULhJB8hvPQBDIwMkbj96An3rWxAxCsi+vGitka9zjzJ6/uf6Hwtcim7hTEEiU+b2DI9kciWiLBmj34RswQISkAd0oAo0gS4wAixgDRyAM3AD3iAAhIBIEAOWAy5IAmlABLJBPtgACkEx2AF2g2pwANSBetAEToI2cAZcBFfADXALDIBHQAqGwUswAd6BaQiC8BAVokGqkBakD5lC1hAbWgh5Q0FQOBQDxUOJkBCSQPnQJqgYKoOqoUNQPfQjdBq6CF2D+qAH0CA0Bv0BfYQRmALTYQ3YALaA2bA7HAhHwsvgRHgVnAcXwNvhSrgWPg63whfhG/AALIVfwpMIQMgIA9FGWAgb8URCkFgkAREha5EipAKpRZqQDqQbuY1IkXHkAwaHoWGYGBbGGeOHWYzhYlZh1mJKMNWYY5hWTBfmNmYQM4H5gqVi1bGmWCesP3YJNhGbjS3EVmCPYFuwl7ED2GHsOxwOx8AZ4hxwfrgYXDJuNa4Etw/XjLuA68MN4SbxeLwq3hTvgg/Bc/BifCG+Cn8cfx7fjx/GvyeQCVoEa4IPIZYgJGwkVBAaCOcI/YQRwjRRgahPdCKGEHnEXGIpsY7YQbxJHCZOkxRJhiQXUiQpmbSBVElqIl0mPSa9IZPJOmRHchhZQF5PriSfIF8lD5I/UJQoJhRPShxFQtlOOUq5QHlAeUOlUg2obtRYqpi6nVpPvUR9Sn0vR5Mzl/OX48mtk6uRa5Xrl3slT5TXl3eXXy6fJ18hf0r+pvy4AlHBQMFTgaOwVqFG4bTCPYVJRZqilWKIYppiiWKD4jXFUSW8koGStxJPqUDpsNIlpSEaQtOledK4tE20Otpl2jAdRzek+9OT6cX0H+i99AllJWVb5SjlHOUa5bPKUgbCMGD4M1IZpYyTjLuMj/M05rnP48/bNq9pXv+8KZX5Km4qfJUilWaVAZWPqkxVb9UU1Z2qbapP1DBqJmphatlq+9Uuq43Pp893ns+dXzT/5PyH6rC6iXq4+mr1w+o96pMamhq+GhkaVRqXNMY1GZpumsma5ZrnNMe0aFoLtQRa5VrntV4wlZnuzFRmJbOLOaGtru2nLdE+pN2rPa1jqLNYZ6NOs84TXZIuWzdBt1y3U3dCT0svWC9fr1HvoT5Rn62fpL9Hv1t/ysDQINpgi0GbwaihiqG/YZ5ho+FjI6qRq9Eqo1qjO8Y4Y7ZxivE+41smsImdSZJJjclNU9jU3lRgus+0zwxr5mgmNKs1u8eisNxZWaxG1qA5wzzIfKN5m/krCz2LWIudFt0WXyztLFMt6ywfWSlZBVhttOqw+sPaxJprXWN9x4Zq42Ozzqbd5rWtqS3fdr/tfTuaXbDdFrtOu8/2DvYi+yb7MQc9h3iHvQ732HR2KLuEfdUR6+jhuM7xjOMHJ3snsdNJp9+dWc4pzg3OowsMF/AX1C0YctFx4bgccpEuZC6MX3hwodRV25XjWuv6zE3Xjed2xG3E3dg92f24+ysPSw+RR4vHlKeT5xrPC16Il69XkVevt5L3Yu9q76c+Oj6JPo0+E752vqt9L/hh/QL9dvrd89fw5/rX+08EOASsCegKpARGBFYHPgsyCRIFdQTDwQHBu4IfL9JfJFzUFgJC/EN2hTwJNQxdFfpzGC4sNKwm7Hm4VXh+eHcELWJFREPEu0iPyNLIR4uNFksWd0bJR8VF1UdNRXtFl0VLl1gsWbPkRoxajCCmPRYfGxV7JHZyqffS3UuH4+ziCuPuLjNclrPs2nK15anLz66QX8FZcSoeGx8d3xD/iRPCqeVMrvRfuXflBNeTu4f7kufGK+eN8V34ZfyRBJeEsoTRRJfEXYljSa5JFUnjAk9BteB1sl/ygeSplJCUoykzqdGpzWmEtPi000IlYYqwK10zPSe9L8M0ozBDuspp1e5VE6JA0ZFMKHNZZruYjv5M9UiMJJslg1kLs2qy3mdHZZ/KUcwR5vTkmuRuyx3J88n7fjVmNXd1Z752/ob8wTXuaw6thdauXNu5Tnddwbrh9b7rj20gbUjZ8MtGy41lG99uit7UUaBRsL5gaLPv5sZCuUJR4b0tzlsObMVsFWzt3WazrWrblyJe0fViy+KK4k8l3JLr31l9V/ndzPaE7b2l9qX7d+B2CHfc3em681iZYlle2dCu4F2t5czyovK3u1fsvlZhW3FgD2mPZI+0MqiyvUqvakfVp+qk6oEaj5rmvep7t+2d2sfb17/fbX/TAY0DxQc+HhQcvH/I91BrrUFtxWHc4azDz+ui6rq/Z39ff0TtSPGRz0eFR6XHwo911TvU1zeoN5Q2wo2SxrHjccdv/eD1Q3sTq+lQM6O5+AQ4ITnx4sf4H++eDDzZeYp9qukn/Z/2ttBailqh1tzWibakNml7THvf6YDTnR3OHS0/m/989Iz2mZqzymdLz5HOFZybOZ93fvJCxoXxi4kXhzpXdD66tOTSna6wrt7LgZevXvG5cqnbvfv8VZerZ645XTt9nX297Yb9jdYeu56WX+x+aem172296XCz/ZbjrY6+BX3n+l37L972un3ljv+dGwOLBvruLr57/17cPel93v3RB6kPXj/Mejj9aP1j7OOiJwpPKp6qP6391fjXZqm99Oyg12DPs4hnj4a4Qy//lfmvT8MFz6nPK0a0RupHrUfPjPmM3Xqx9MXwy4yX0+OFvyn+tveV0auffnf7vWdiycTwa9HrmT9K3qi+OfrW9m3nZOjk03dp76anit6rvj/2gf2h+2P0x5Hp7E/4T5WfjT93fAn88ngmbWbm3/eE8/syOll+AAAACXBIWXMAAAsTAAALEwEAmpwYAAAEImlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC8iCiAgICAgICAgICAgIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIj4KICAgICAgICAgPHRpZmY6UmVzb2x1dGlvblVuaXQ+MTwvdGlmZjpSZXNvbHV0aW9uVW5pdD4KICAgICAgICAgPHRpZmY6Q29tcHJlc3Npb24+NTwvdGlmZjpDb21wcmVzc2lvbj4KICAgICAgICAgPHRpZmY6WFJlc29sdXRpb24+NzI8L3RpZmY6WFJlc29sdXRpb24+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgICAgIDx0aWZmOllSZXNvbHV0aW9uPjcyPC90aWZmOllSZXNvbHV0aW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFhEaW1lbnNpb24+MzI8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpDb2xvclNwYWNlPjE8L2V4aWY6Q29sb3JTcGFjZT4KICAgICAgICAgPGV4aWY6UGl4ZWxZRGltZW5zaW9uPjIwPC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgICAgPGRjOnN1YmplY3Q+CiAgICAgICAgICAgIDxyZGY6QmFnLz4KICAgICAgICAgPC9kYzpzdWJqZWN0PgogICAgICAgICA8eG1wOk1vZGlmeURhdGU+MjAxNS0wNi0xNFQxOTowNjo1OTwveG1wOk1vZGlmeURhdGU+CiAgICAgICAgIDx4bXA6Q3JlYXRvclRvb2w+UGl4ZWxtYXRvciAzLjI8L3htcDpDcmVhdG9yVG9vbD4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Ch7v5WoAAAGgSURBVEgNYywtLbVnYmLqYmBgMANieoJT//79K2MBWr4CaKsEPW2G2mUGspsFZnlnZycjPR1RXl7+H2Q3Ez0txWbXgDsAFAUYABo8YPH////HdXV1LUZWVFZWFsvIyLgIJoYt+pDNwCYP00swBIAWzaysrNSCaQCxgWLTYHxKaawhgGYoJzC7rC4sLDQBiYPYQIoHTQ3ZXGIcADJci42NDeZreGiQbSuSRmKiABb/CUB9IMwAjAKYGIhLESAYAj9//kwH+t4YaAvM59c4ODiyvn//HotuMzDh9QLFirCIg/I8CPQBE2QxhAkhCYZAf3//d2CJFQpU/h2EQeyGhoYvyIbA2FDDl8H4aPQydMtB8gQdAFLU3t5+DRjsWSAMYoPEcAFOTs5EoNw+NPl9UHE0YQYGglEA09HR0bEAxsZHA0PnFzAqgoBq9gIxKOrOAnEQSBxIYwCiQgBDFwEBYFB/BEaVJ7AQ2wGiQXxcWhhhJRZQ0UBURsSlAVyup4Y4TaKAFIeBouAJUIM0KZqoqPYpEzBrpQANfEFFQ4k16gXIbgCggnKoJ5DJdwAAAABJRU5ErkJggg==" alt="MD Logo" /> and text</a></p>
================================================
FILE: test/data/inline_link_title.html
================================================
<p><a href="http://example.com" title="Title">single quotes</a></p>
<p><a href="http://example.com" title="Title">double quotes</a></p>
<p><a href="http://example.com" title="">single quotes blank</a></p>
<p><a href="http://example.com" title="">double quotes blank</a></p>
<p><a href="http://example.com" title="2 Words">space</a></p>
<p><a href="http://example.com/url-(parentheses)" title="Title">parentheses</a></p>
================================================
FILE: test/data/inline_title.html
================================================
<p><a href="http://example.com" title="Example">single quotes</a> and <a href="http://example.com" title="Example">double quotes</a></p>
================================================
FILE: test/data/lazy_blockquote.html
================================================
<blockquote>
<p>quote
the rest of it</p>
</blockquote>
<blockquote>
<p>another paragraph
the rest of it</p>
</blockquote>
================================================
FILE: test/data/lazy_list.html
================================================
<ul>
<li>li
the rest of it</li>
</ul>
================================================
FILE: test/data/line_break.html
================================================
<p>line<br />
line</p>
================================================
FILE: test/data/markup_consecutive_one.html
================================================
<div>Markup</div>
_No markdown_ without blank line for **strict** compliance with CommonMark.
<p><strong>Markdown</strong></p>
================================================
FILE: test/data/markup_consecutive_one_line.html
================================================
<div>One markup on
two lines</div>
_No markdown_
<p><strong>Markdown</strong></p>
================================================
FILE: test/data/markup_consecutive_one_stripped.html
================================================
<div><p>Stripped markup</p></div>
_No markdown_
<p><strong>Markdown</strong></p>
================================================
FILE: test/data/markup_consecutive_two.html
================================================
<div>First markup</div><p>and second markup on the same line.</p>
_No markdown_
<p><strong>Markdown</strong></p>
================================================
FILE: test/data/markup_consecutive_two_lines.html
================================================
<div>First markup</div><p>and partial markup
on two lines.</p>
_No markdown_
<p><strong>Markdown</strong></p>
================================================
FILE: test/data/markup_consecutive_two_stripped.html
================================================
<div><p>Stripped markup
on two lines</p></div>
_No markdown_
<p><strong>Markdown</strong></p>
================================================
FILE: test/data/multiline_list_paragraph.html
================================================
<ul>
<li>
<p>li</p>
<p>line
line</p>
</li>
</ul>
================================================
FILE: test/data/multiline_lists.html
================================================
<ol>
<li>
<p>One
First body copy</p>
</li>
<li>
<p>Two
Last body copy</p>
</li>
</ol>
================================================
FILE: test/data/nested_block-level_html.html
================================================
<div>
_parent_
<div>
_child_
</div>
<pre>
_adopted child_
</pre>
</div>
<p><em>outside</em></p>
================================================
FILE: test/data/ordered_list.html
================================================
<ol>
<li>one</li>
<li>two</li>
</ol>
<p>repeating numbers:</p>
<ol>
<li>one</li>
<li>two</li>
</ol>
<p>large numbers:</p>
<ol start="123">
<li>one</li>
</ol>
<p>foo 1. the following should not start a list
100.<br />
200. </p>
================================================
FILE: test/data/paragraph_list.html
================================================
<p>paragraph</p>
<ul>
<li>li</li>
<li>li</li>
</ul>
<p>paragraph</p>
<ul>
<li>
<p>li</p>
</li>
<li>
<p>li</p>
</li>
</ul>
================================================
FILE: test/data/reference_title.html
================================================
<p><a href="http://example.com" title="example title">double quotes</a> and <a href="http://example.com" title="example title">single quotes</a> and <a href="http://example.com" title="example title">parentheses</a></p>
<p>[invalid title]: <a href="http://example.com">http://example.com</a> example title</p>
================================================
FILE: test/data/self-closing_html.html
================================================
<hr>
<p>paragraph</p>
<hr/>
<p>paragraph</p>
<hr />
<p>paragraph</p>
<hr class="foo" id="bar" />
<p>paragraph</p>
<hr class="foo" id="bar"/>
<p>paragraph</p>
<hr class="foo" id="bar" >
<p>paragraph</p>
================================================
FILE: test/data/separated_nested_list.html
================================================
<ul>
<li>
<p>li</p>
<ul>
<li>li</li>
<li>li</li>
</ul>
</li>
</ul>
================================================
FILE: test/data/setext_header.html
================================================
<h1>h1</h1>
<h2>h2</h2>
<h2>single character</h2>
<p>not a header</p>
<hr />
================================================
FILE: test/data/setext_header_spaces.html
================================================
<h1>trailing space</h1>
<h2>trailing space</h2>
<h1>leading and trailing space</h1>
<h2>leading and trailing space</h2>
<h1>1 leading space</h1>
<h2>1 leading space</h2>
<h1>3 leading spaces</h1>
<h2>3 leading spaces</h2>
<p>too many leading spaces
==</p>
<p>too many leading spaces
--</p>
================================================
FILE: test/data/simple_blockquote.html
================================================
<blockquote>
<p>quote</p>
</blockquote>
<p>indented:</p>
<blockquote>
<p>quote</p>
</blockquote>
<p>no space after <code>></code>:</p>
<blockquote>
<p>quote</p>
</blockquote>
<hr />
<blockquote>
<blockquote>
<blockquote>
<p>Info 1 text</p>
</blockquote>
</blockquote>
</blockquote>
<blockquote>
<blockquote>
<blockquote>
<p>Info 2 text</p>
</blockquote>
</blockquote>
</blockquote>
================================================
FILE: test/data/simple_table.html
================================================
<table>
<thead>
<tr>
<th>header 1</th>
<th>header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>cell 1.1</td>
<td>cell 1.2</td>
</tr>
<tr>
<td>cell 2.1</td>
<td>cell 2.2</td>
</tr>
</tbody>
</table>
<hr />
<table>
<thead>
<tr>
<th style="text-align: left;">header 1</th>
<th>header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">cell 1.1</td>
<td>cell 1.2</td>
</tr>
<tr>
<td style="text-align: left;">cell 2.1</td>
<td>cell 2.2</td>
</tr>
</tbody>
</table>
<hr />
<table>
<thead>
<tr>
<th style="text-align: left;">header 1</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">cell 1.1</td>
</tr>
<tr>
<td style="text-align: left;">cell 2.1</td>
</tr>
</tbody>
</table>
<hr />
<table>
<thead>
<tr>
<th>header 1</th>
</tr>
</thead>
<tbody>
<tr>
<td>cell 1.1</td>
</tr>
<tr>
<td>cell 2.1</td>
</tr>
</tbody>
</table>
<hr />
<p>Not a table, we haven't ended the paragraph:
header 1 | header 2
-------- | --------
cell 1.1 | cell 1.2
cell 2.1 | cell 2.2</p>
================================================
FILE: test/data/span-level_html.html
================================================
<p>an <b>important</b> <a href=''>link</a></p>
<p>broken<br/>
line</p>
<p><b>inline tag</b> at the beginning</p>
<p><span><a href="http://example.com">http://example.com</a></span></p>
================================================
FILE: test/data/sparse_dense_list.html
================================================
<ul>
<li>
<p>li</p>
</li>
<li>
<p>li</p>
</li>
<li>
<p>li</p>
</li>
</ul>
================================================
FILE: test/data/sparse_html.html
================================================
<div>
line 1
<p>line 2
line 3</p>
<p>line 4</p>
</div>
================================================
FILE: test/data/sparse_list.html
================================================
<ul>
<li>
<p>li</p>
</li>
<li>
<p>li</p>
</li>
</ul>
<hr />
<ul>
<li>
<p>li</p>
<ul>
<li>indented li</li>
</ul>
</li>
</ul>
================================================
FILE: test/data/special_characters.html
================================================
<p>AT&T has an ampersand in their name</p>
<p>this & that</p>
<p>4 < 5 and 6 > 5</p>
<p><a href="http://example.com/autolink?a=1&b=2">http://example.com/autolink?a=1&b=2</a></p>
<p><a href="/script?a=1&b=2">inline link</a></p>
<p><a href="http://example.com/?a=1&b=2">reference link</a></p>
================================================
FILE: test/data/strict_atx_heading.html
================================================
<h1>h1</h1>
<h2>h2</h2>
<h3>h3</h3>
<h4>h4</h4>
<h5>h5</h5>
<h6>h6</h6>
<p>####### not a heading</p>
<p>#not a heading</p>
<h1>closed h1</h1>
<h1></h1>
<h2></h2>
<h1># of levels</h1>
<h1># of levels #</h1>
================================================
FILE: test/data/strikethrough.html
================================================
<p><del>strikethrough</del></p>
<p>here's <del>one</del> followed by <del>another one</del></p>
<p>~~ this ~~ is not one neither is ~this~</p>
<p>escaped ~~this~~</p>
================================================
FILE: test/data/strong_em.html
================================================
<p><em>em <strong>strong em</strong></em></p>
<p><em><strong>strong em</strong> em</em></p>
<p><em>em <strong>strong em</strong> em</em></p>
<p><em>em <strong>strong em</strong></em></p>
<p><em><strong>strong em</strong> em</em></p>
<p><em>em <strong>strong em</strong> em</em></p>
================================================
FILE: test/data/tab-indented_code_block.html
================================================
<pre><code><?php
$message = 'Hello World!';
echo $message;
echo "following a blank line";</code></pre>
================================================
FILE: test/data/table_inline_markdown.html
================================================
<table>
<thead>
<tr>
<th><em>header</em> 1</th>
<th>header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td><em>cell</em> 1.1</td>
<td><del>cell</del> 1.2</td>
</tr>
<tr>
<td><code>|</code> 2.1</td>
<td>| 2.2</td>
</tr>
<tr>
<td><code>\|</code> 2.1</td>
<td><a href="/">link</a></td>
</tr>
</tbody>
</table>
================================================
FILE: test/data/text_reference.html
================================================
<p><a href="http://example.com">reference link</a></p>
<p><a href="http://example.com">one</a> with a semantic name</p>
<p>[one][404] with no definition</p>
<p><a href="http://example.com">multiline
one</a> defined on 2 lines</p>
<p><a href="http://example.com">one</a> with a mixed case label and an upper case definition</p>
<p><a href="http://example.com">one</a> with the a label on the next line</p>
<p><a href="http://example.com"><code>link</code></a></p>
================================================
FILE: test/data/unordered_list.html
================================================
<ul>
<li>li</li>
<li>li</li>
</ul>
<p>mixed unordered markers:</p>
<ul>
<li>li</li>
</ul>
<ul>
<li>li</li>
</ul>
<ul>
<li>li</li>
</ul>
<p>mixed ordered markers:</p>
<ol>
<li>starting at 1, list one</li>
<li>number 2, list one</li>
</ol>
<ol start="3">
<li>starting at 3, list two</li>
</ol>
================================================
FILE: test/data/untidy_table.html
================================================
<table>
<thead>
<tr>
<th>header 1</th>
<th>header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>cell 1.1</td>
<td>cell 1.2</td>
</tr>
<tr>
<td>cell 2.1</td>
<td>cell 2.2</td>
</tr>
</tbody>
</table>
================================================
FILE: test/data/url_autolinking.html
================================================
<p>an autolink <a href="http://example.com">http://example.com</a></p>
<p>inside of brackets [<a href="http://example.com">http://example.com</a>], inside of braces {<a href="http://example.com">http://example.com</a>}, inside of parentheses (<a href="http://example.com">http://example.com</a>)</p>
<p>trailing slash <a href="http://example.com/">http://example.com/</a> and <a href="http://example.com/path/">http://example.com/path/</a></p>
================================================
FILE: test/data/whitespace.html
================================================
<pre><code>code</code></pre>
================================================
FILE: test/data/xss_attribute_encoding.html
================================================
<p><a href="https://www.example.com"">xss</a></p>
<p><img src="https://www.example.com"" alt="xss" /></p>
<p><a href="https://www.example.com'">xss</a></p>
<p><img src="https://www.example.com'" alt="xss" /></p>
<p><img src="https://www.example.com" alt="xss"" /></p>
<p><img src="https://www.example.com" alt="xss'" /></p>
================================================
FILE: test/data/xss_bad_url.html
================================================
<p><a href="javascript%3Aalert(1)">xss</a></p>
<p><a href="javascript%3Aalert(1)">xss</a></p>
<p><a href="javascript%3A//alert(1)">xss</a></p>
<p><a href="javascript&colon;alert(1)">xss</a></p>
<p><img src="javascript%3Aalert(1)" alt="xss" /></p>
<p><img src="javascript%3Aalert(1)" alt="xss" /></p>
<p><img src="javascript%3A//alert(1)" alt="xss" /></p>
<p><img src="javascript&colon;alert(1)" alt="xss" /></p>
<p><a href="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">xss</a></p>
<p><a href="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">xss</a></p>
<p><a href="data%3A//text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">xss</a></p>
<p><a href="data&colon;text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">xss</a></p>
<p><img src="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" alt="xss" /></p>
<p><img src="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" alt="xss" /></p>
<p><img src="data%3A//text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" alt="xss" /></p>
<p><img src="data&colon;text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" alt="xss" /></p>
================================================
FILE: test/data/xss_text_encoding.html
================================================
<p><script>alert(1)</script></p>
<p><script></p>
<p>alert(1)</p>
<p></script></p>
<p><script>
alert(1)
</script></p>
gitextract_8dv4ybdv/
├── .gitattributes
├── .github/
│ └── workflows/
│ └── unit-tests.yaml
├── .gitignore
├── LICENSE.txt
├── Parsedown.php
├── composer.json
├── phpunit.xml.dist
├── readme.md
└── test/
├── CommonMarkTestStrict.php
├── CommonMarkTestWeak.php
├── ParsedownTest.php
├── SampleExtensions.php
├── TestParsedown.php
└── data/
├── aesthetic_table.html
├── aligned_table.html
├── atx_heading.html
├── automatic_link.html
├── block-level_html.html
├── code_block.html
├── code_span.html
├── compound_blockquote.html
├── compound_emphasis.html
├── compound_list.html
├── deeply_nested_list.html
├── em_strong.html
├── email.html
├── emphasis.html
├── escaping.html
├── fenced_code_block.html
├── horizontal_rule.html
├── html_comment.html
├── html_entity.html
├── image_reference.html
├── image_title.html
├── implicit_reference.html
├── inline_link.html
├── inline_link_title.html
├── inline_title.html
├── lazy_blockquote.html
├── lazy_list.html
├── line_break.html
├── markup_consecutive_one.html
├── markup_consecutive_one_line.html
├── markup_consecutive_one_stripped.html
├── markup_consecutive_two.html
├── markup_consecutive_two_lines.html
├── markup_consecutive_two_stripped.html
├── multiline_list_paragraph.html
├── multiline_lists.html
├── nested_block-level_html.html
├── ordered_list.html
├── paragraph_list.html
├── reference_title.html
├── self-closing_html.html
├── separated_nested_list.html
├── setext_header.html
├── setext_header_spaces.html
├── simple_blockquote.html
├── simple_table.html
├── span-level_html.html
├── sparse_dense_list.html
├── sparse_html.html
├── sparse_list.html
├── special_characters.html
├── strict_atx_heading.html
├── strikethrough.html
├── strong_em.html
├── tab-indented_code_block.html
├── table_inline_markdown.html
├── text_reference.html
├── unordered_list.html
├── untidy_table.html
├── url_autolinking.html
├── whitespace.html
├── xss_attribute_encoding.html
├── xss_bad_url.html
└── xss_text_encoding.html
SYMBOL INDEX (92 symbols across 6 files)
FILE: Parsedown.php
class Parsedown (line 16) | class Parsedown
method text (line 24) | function text($text)
method textElements (line 37) | protected function textElements($text)
method setBreaksEnabled (line 59) | function setBreaksEnabled($breaksEnabled)
method setMarkupEscaped (line 68) | function setMarkupEscaped($markupEscaped)
method setUrlsLinked (line 77) | function setUrlsLinked($urlsLinked)
method setSafeMode (line 86) | function setSafeMode($safeMode)
method setStrictMode (line 95) | function setStrictMode($strictMode)
method lines (line 162) | protected function lines(array $lines)
method linesElements (line 167) | protected function linesElements(array $lines)
method extractElement (line 319) | protected function extractElement(array $Component)
method isBlockContinuable (line 336) | protected function isBlockContinuable($Type)
method isBlockCompletable (line 341) | protected function isBlockCompletable($Type)
method blockCode (line 349) | protected function blockCode($Line, $Block = null)
method blockCodeContinue (line 374) | protected function blockCodeContinue($Line, $Block)
method blockCodeComplete (line 395) | protected function blockCodeComplete($Block)
method blockComment (line 403) | protected function blockComment($Line)
method blockCommentContinue (line 428) | protected function blockCommentContinue($Line, array $Block)
method blockFencedCode (line 448) | protected function blockFencedCode($Line)
method blockFencedCodeContinue (line 502) | protected function blockFencedCodeContinue($Line, $Block)
method blockFencedCodeComplete (line 531) | protected function blockFencedCodeComplete($Block)
method blockHeader (line 539) | protected function blockHeader($Line)
method blockList (line 574) | protected function blockList($Line, ?array $CurrentBlock = null)
method blockListContinue (line 643) | protected function blockListContinue($Line, array $Block)
method blockListComplete (line 729) | protected function blockListComplete(array $Block)
method blockQuote (line 748) | protected function blockQuote($Line)
method blockQuoteContinue (line 767) | protected function blockQuoteContinue($Line, array $Block)
method blockRule (line 792) | protected function blockRule($Line)
method blockSetextHeader (line 811) | protected function blockSetextHeader($Line, ?array $Block = null)
method blockMarkup (line 829) | protected function blockMarkup($Line)
method blockMarkupContinue (line 857) | protected function blockMarkupContinue($Line, array $Block)
method blockReference (line 872) | protected function blockReference($Line)
method blockTable (line 897) | protected function blockTable($Line, ?array $Block = null)
method blockTableContinue (line 1020) | protected function blockTableContinue($Line, array $Block)
method paragraph (line 1078) | protected function paragraph($Line)
method paragraphContinue (line 1093) | protected function paragraphContinue($Line, array $Block)
method line (line 1130) | public function line($text, $nonNestables = array())
method lineElements (line 1135) | protected function lineElements($text, $nonNestables = array())
method inlineText (line 1239) | protected function inlineText($text)
method inlineCode (line 1258) | protected function inlineCode($Excerpt)
method inlineEmailTag (line 1277) | protected function inlineEmailTag($Excerpt)
method inlineEmphasis (line 1307) | protected function inlineEmphasis($Excerpt)
method inlineEscapeSequence (line 1342) | protected function inlineEscapeSequence($Excerpt)
method inlineImage (line 1353) | protected function inlineImage($Excerpt)
method inlineLink (line 1388) | protected function inlineLink($Excerpt)
method inlineMarkup (line 1463) | protected function inlineMarkup($Excerpt)
method inlineSpecialCharacter (line 1495) | protected function inlineSpecialCharacter($Excerpt)
method inlineStrikethrough (line 1507) | protected function inlineStrikethrough($Excerpt)
method inlineUrl (line 1530) | protected function inlineUrl($Excerpt)
method inlineUrlTag (line 1558) | protected function inlineUrlTag($Excerpt)
method unmarkedText (line 1579) | protected function unmarkedText($text)
method handle (line 1589) | protected function handle(array $Element)
method handleElementRecursive (line 1625) | protected function handleElementRecursive(array $Element)
method handleElementsRecursive (line 1630) | protected function handleElementsRecursive(array $Elements)
method elementApplyRecursive (line 1635) | protected function elementApplyRecursive($closure, array $Element)
method elementApplyRecursiveDepthFirst (line 1651) | protected function elementApplyRecursiveDepthFirst($closure, array $El...
method elementsApplyRecursive (line 1667) | protected function elementsApplyRecursive($closure, array $Elements)
method elementsApplyRecursiveDepthFirst (line 1677) | protected function elementsApplyRecursiveDepthFirst($closure, array $E...
method element (line 1687) | protected function element(array $Element)
method elements (line 1771) | protected function elements(array $Elements)
method li (line 1801) | protected function li($lines)
method pregReplaceElements (line 1823) | protected static function pregReplaceElements($regexp, $Elements, $text)
method parse (line 1855) | function parse($text)
method sanitiseElement (line 1862) | protected function sanitiseElement(array $Element)
method filterUnsafeUrlInAttribute (line 1901) | protected function filterUnsafeUrlInAttribute(array $Element, $attribute)
method escape (line 1920) | protected static function escape($text, $allowQuotes = false)
method striAtStart (line 1925) | protected static function striAtStart($string, $needle)
method instance (line 1939) | static function instance($name = 'default')
FILE: test/CommonMarkTestStrict.php
class CommonMarkTestStrict (line 10) | class CommonMarkTestStrict extends TestCase
method setUp (line 16) | protected function setUp() : void
method testExample (line 29) | public function testExample($id, $section, $markdown, $expectedHtml)
method data (line 38) | public function data()
FILE: test/CommonMarkTestWeak.php
class CommonMarkTestWeak (line 16) | class CommonMarkTestWeak extends CommonMarkTestStrict
method setUp (line 20) | protected function setUp() : void
method testExample (line 38) | public function testExample($id, $section, $markdown, $expectedHtml)
method cleanupHtml (line 48) | protected function cleanupHtml($markup)
FILE: test/ParsedownTest.php
class ParsedownTest (line 6) | class ParsedownTest extends TestCase
method __construct (line 8) | final function __construct($name = null, array $data = array(), $dataN...
method initDirs (line 22) | protected function initDirs()
method initParsedown (line 32) | protected function initParsedown()
method test_ (line 44) | function test_($test, $dir)
method testRawHtml (line 61) | function testRawHtml()
method testTrustDelegatedRawHtml (line 78) | function testTrustDelegatedRawHtml()
method data (line 95) | function data()
method test_no_markup (line 133) | public function test_no_markup()
method testLateStaticBinding (line 182) | public function testLateStaticBinding()
FILE: test/SampleExtensions.php
class UnsafeExtension (line 3) | class UnsafeExtension extends Parsedown
method blockFencedCodeComplete (line 5) | protected function blockFencedCodeComplete($Block)
class TrustDelegatedExtension (line 22) | class TrustDelegatedExtension extends Parsedown
method blockFencedCodeComplete (line 24) | protected function blockFencedCodeComplete($Block)
FILE: test/TestParsedown.php
class TestParsedown (line 3) | class TestParsedown extends Parsedown
method getTextLevelElements (line 5) | public function getTextLevelElements()
Condensed preview — 77 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (99K chars).
[
{
"path": ".gitattributes",
"chars": 201,
"preview": "# Ignore all tests for archive\n/test export-ignore\n/.gitattributes export-ignore\n/.gitignore e"
},
{
"path": ".github/workflows/unit-tests.yaml",
"chars": 859,
"preview": "on:\n - push\n - pull_request\n\njobs:\n phpunit:\n runs-on: ubuntu-latest\n\n strategy:\n matr"
},
{
"path": ".gitignore",
"chars": 61,
"preview": "*.md\n!readme.md\n\ncomposer.lock\nvendor/\n.phpunit.result.cache\n"
},
{
"path": "LICENSE.txt",
"chars": 1097,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2013-2018 Emanuil Rusev, erusev.com\n\nPermission is hereby granted, free of charge, "
},
{
"path": "Parsedown.php",
"chars": 52070,
"preview": "<?php\n\n#\n#\n# Parsedown\n# http://parsedown.org\n#\n# (c) Emanuil Rusev\n# http://erusev.com\n#\n# For the full license informa"
},
{
"path": "composer.json",
"chars": 795,
"preview": "{\n \"name\": \"erusev/parsedown\",\n \"description\": \"Parser for Markdown.\",\n \"keywords\": [\"markdown\", \"parser\"],\n "
},
{
"path": "phpunit.xml.dist",
"chars": 220,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit bootstrap=\"vendor/autoload.php\" colors=\"true\">\n\t<testsuites>\n\t\t<testsuit"
},
{
"path": "readme.md",
"chars": 4621,
"preview": "# Parsedown\n\n[](https://packagist.org/packages/er"
},
{
"path": "test/CommonMarkTestStrict.php",
"chars": 2011,
"preview": "<?php\n\nuse PHPUnit\\Framework\\TestCase;\n\n/**\n * Test Parsedown against the CommonMark spec\n *\n * @link http://commonmark."
},
{
"path": "test/CommonMarkTestWeak.php",
"chars": 2155,
"preview": "<?php\nrequire_once(__DIR__ . '/CommonMarkTestStrict.php');\n\n/**\n * Test Parsedown against the CommonMark spec, but less "
},
{
"path": "test/ParsedownTest.php",
"chars": 5069,
"preview": "<?php\nrequire 'SampleExtensions.php';\n\nuse PHPUnit\\Framework\\TestCase;\n\nclass ParsedownTest extends TestCase\n{\n final"
},
{
"path": "test/SampleExtensions.php",
"chars": 1335,
"preview": "<?php\n\nclass UnsafeExtension extends Parsedown\n{\n protected function blockFencedCodeComplete($Block)\n {\n $t"
},
{
"path": "test/TestParsedown.php",
"chars": 145,
"preview": "<?php\n\nclass TestParsedown extends Parsedown\n{\n public function getTextLevelElements()\n {\n return $this->te"
},
{
"path": "test/data/aesthetic_table.html",
"chars": 191,
"preview": "<table>\n<thead>\n<tr>\n<th>header 1</th>\n<th>header 2</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>cell 1.1</td>\n<td>cell 1.2</td>"
},
{
"path": "test/data/aligned_table.html",
"chars": 488,
"preview": "<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">header 1</th>\n<th style=\"text-align: center;\">header 2</th>\n<th style"
},
{
"path": "test/data/atx_heading.html",
"chars": 200,
"preview": "<h1>h1</h1>\n<h2>h2</h2>\n<h3>h3</h3>\n<h4>h4</h4>\n<h5>h5</h5>\n<h6>h6</h6>\n<p>####### not a heading</p>\n<h1>closed h1</h1>\n"
},
{
"path": "test/data/automatic_link.html",
"chars": 58,
"preview": "<p><a href=\"http://example.com\">http://example.com</a></p>"
},
{
"path": "test/data/block-level_html.html",
"chars": 182,
"preview": "<div>_content_</div>\n<p>paragraph</p>\n<div>\n <div class=\"inner\">\n _content_\n </div>\n</div>\n<style type=\"text/css\">\n"
},
{
"path": "test/data/code_block.html",
"chars": 216,
"preview": "<pre><code><?php\n\n$message = 'Hello World!';\necho $message;</code></pre>\n<hr />\n<pre><code>> not a quote\n- not a l"
},
{
"path": "test/data/code_span.html",
"chars": 284,
"preview": "<p>a <code>code span</code></p>\n<p><code>this is also a codespan</code> trailing text</p>\n<p><code>and look at this one!"
},
{
"path": "test/data/compound_blockquote.html",
"chars": 106,
"preview": "<blockquote>\n<h2>header</h2>\n<p>paragraph</p>\n<ul>\n<li>li</li>\n</ul>\n<hr />\n<p>paragraph</p>\n</blockquote>"
},
{
"path": "test/data/compound_emphasis.html",
"chars": 153,
"preview": "<p><em><code>code</code></em> <strong><code>code</code></strong></p>\n<p><em><code>code</code><strong><code>code</code></"
},
{
"path": "test/data/compound_list.html",
"chars": 123,
"preview": "<ul>\n<li>\n<p>paragraph</p>\n<p>paragraph</p>\n</li>\n<li>\n<p>paragraph</p>\n<blockquote>\n<p>quote</p>\n</blockquote>\n</li>\n</"
},
{
"path": "test/data/deeply_nested_list.html",
"chars": 368,
"preview": "<ul>\n<li>li<ul>\n<li>li<ul>\n<li>li</li>\n<li>li</li>\n</ul>\n</li>\n<li>li</li>\n</ul>\n</li>\n<li>li</li>\n</ul>\n<hr />\n<ul>\n<li"
},
{
"path": "test/data/em_strong.html",
"chars": 399,
"preview": "<p><strong><em>em strong</em></strong></p>\n<p><strong><em>em strong</em> strong</strong></p>\n<p><strong>strong <em>em st"
},
{
"path": "test/data/email.html",
"chars": 160,
"preview": "<p>my email is <a href=\"mailto:me@example.com\">me@example.com</a></p>\n<p>html tags shouldn't start an email autolink <st"
},
{
"path": "test/data/emphasis.html",
"chars": 370,
"preview": "<p><em>underscore</em>, <em>asterisk</em>, <em>one two</em>, <em>three four</em>, <em>a</em>, <em>b</em></p>\n<p><strong>"
},
{
"path": "test/data/escaping.html",
"chars": 280,
"preview": "<p>escaped *emphasis*.</p>\n<p><code>escaped \\*emphasis\\* in a code span</code></p>\n<pre><code>escaped \\*emphasis\\* in a "
},
{
"path": "test/data/fenced_code_block.html",
"chars": 618,
"preview": "<pre><code><?php\n\n$message = 'fenced code block';\necho $message;</code></pre>\n<pre><code>tilde</code></pre>\n<pre><cod"
},
{
"path": "test/data/horizontal_rule.html",
"chars": 34,
"preview": "<hr />\n<hr />\n<hr />\n<hr />\n<hr />"
},
{
"path": "test/data/html_comment.html",
"chars": 145,
"preview": "<!-- single line -->\n<p>paragraph</p>\n<!-- \n multiline -->\n<p>paragraph</p>\n<!-- sss -->abc\n<ul>\n<li>abcd</li>\n<li>bbbb"
},
{
"path": "test/data/html_entity.html",
"chars": 26,
"preview": "<p>& © {</p>"
},
{
"path": "test/data/image_reference.html",
"chars": 76,
"preview": "<p><img src=\"/md.png\" alt=\"Markdown Logo\" /></p>\n<p>![missing reference]</p>"
},
{
"path": "test/data/image_title.html",
"chars": 108,
"preview": "<p><img src=\"/md.png\" alt=\"alt\" title=\"title\" /></p>\n<p><img src=\"/md.png\" alt=\"blank title\" title=\"\" /></p>"
},
{
"path": "test/data/implicit_reference.html",
"chars": 375,
"preview": "<p>an <a href=\"http://example.com\">implicit</a> reference link</p>\n<p>an <a href=\"http://example.com\">implicit</a> refer"
},
{
"path": "test/data/inline_link.html",
"chars": 6131,
"preview": "<p><a href=\"http://example.com\">link</a></p>\n<p><a href=\"/url-(parentheses)\">link</a> with parentheses in URL </p>\n<p>(<"
},
{
"path": "test/data/inline_link_title.html",
"chars": 419,
"preview": "<p><a href=\"http://example.com\" title=\"Title\">single quotes</a></p>\n<p><a href=\"http://example.com\" title=\"Title\">double"
},
{
"path": "test/data/inline_title.html",
"chars": 136,
"preview": "<p><a href=\"http://example.com\" title=\"Example\">single quotes</a> and <a href=\"http://example.com\" title=\"Example\">doubl"
},
{
"path": "test/data/lazy_blockquote.html",
"chars": 121,
"preview": "<blockquote>\n<p>quote\nthe rest of it</p>\n</blockquote>\n<blockquote>\n<p>another paragraph\nthe rest of it</p>\n</blockquote"
},
{
"path": "test/data/lazy_list.html",
"chars": 37,
"preview": "<ul>\n<li>li\nthe rest of it</li>\n</ul>"
},
{
"path": "test/data/line_break.html",
"chars": 22,
"preview": "<p>line<br />\nline</p>"
},
{
"path": "test/data/markup_consecutive_one.html",
"chars": 126,
"preview": "<div>Markup</div>\n_No markdown_ without blank line for **strict** compliance with CommonMark.\n<p><strong>Markdown</stron"
},
{
"path": "test/data/markup_consecutive_one_line.html",
"chars": 81,
"preview": "<div>One markup on\ntwo lines</div>\n_No markdown_\n<p><strong>Markdown</strong></p>"
},
{
"path": "test/data/markup_consecutive_one_stripped.html",
"chars": 80,
"preview": "<div><p>Stripped markup</p></div>\n_No markdown_\n<p><strong>Markdown</strong></p>"
},
{
"path": "test/data/markup_consecutive_two.html",
"chars": 112,
"preview": "<div>First markup</div><p>and second markup on the same line.</p>\n_No markdown_\n<p><strong>Markdown</strong></p>"
},
{
"path": "test/data/markup_consecutive_two_lines.html",
"chars": 109,
"preview": "<div>First markup</div><p>and partial markup\non two lines.</p>\n_No markdown_\n<p><strong>Markdown</strong></p>"
},
{
"path": "test/data/markup_consecutive_two_stripped.html",
"chars": 93,
"preview": "<div><p>Stripped markup\non two lines</p></div>\n_No markdown_\n<p><strong>Markdown</strong></p>"
},
{
"path": "test/data/multiline_list_paragraph.html",
"chars": 48,
"preview": "<ul>\n<li>\n<p>li</p>\n<p>line\nline</p>\n</li>\n</ul>"
},
{
"path": "test/data/multiline_lists.html",
"chars": 85,
"preview": "<ol>\n<li>\n<p>One\nFirst body copy</p>\n</li>\n<li>\n<p>Two\nLast body copy</p>\n</li>\n</ol>"
},
{
"path": "test/data/nested_block-level_html.html",
"chars": 95,
"preview": "<div>\n_parent_\n<div>\n_child_\n</div>\n<pre>\n_adopted child_\n</pre>\n</div>\n<p><em>outside</em></p>"
},
{
"path": "test/data/ordered_list.html",
"chars": 226,
"preview": "<ol>\n<li>one</li>\n<li>two</li>\n</ol>\n<p>repeating numbers:</p>\n<ol>\n<li>one</li>\n<li>two</li>\n</ol>\n<p>large numbers:</p"
},
{
"path": "test/data/paragraph_list.html",
"chars": 121,
"preview": "<p>paragraph</p>\n<ul>\n<li>li</li>\n<li>li</li>\n</ul>\n<p>paragraph</p>\n<ul>\n<li>\n<p>li</p>\n</li>\n<li>\n<p>li</p>\n</li>\n</ul"
},
{
"path": "test/data/reference_title.html",
"chars": 309,
"preview": "<p><a href=\"http://example.com\" title=\"example title\">double quotes</a> and <a href=\"http://example.com\" title=\"example "
},
{
"path": "test/data/self-closing_html.html",
"chars": 201,
"preview": "<hr>\n<p>paragraph</p>\n<hr/>\n<p>paragraph</p>\n<hr />\n<p>paragraph</p>\n<hr class=\"foo\" id=\"bar\" />\n<p>paragraph</p>\n<hr cl"
},
{
"path": "test/data/separated_nested_list.html",
"chars": 66,
"preview": "<ul>\n<li>\n<p>li</p>\n<ul>\n<li>li</li>\n<li>li</li>\n</ul>\n</li>\n</ul>"
},
{
"path": "test/data/setext_header.html",
"chars": 76,
"preview": "<h1>h1</h1>\n<h2>h2</h2>\n<h2>single character</h2>\n<p>not a header</p>\n<hr />"
},
{
"path": "test/data/setext_header_spaces.html",
"chars": 289,
"preview": "<h1>trailing space</h1>\n<h2>trailing space</h2>\n<h1>leading and trailing space</h1>\n<h2>leading and trailing space</h2>\n"
},
{
"path": "test/data/simple_blockquote.html",
"chars": 384,
"preview": "<blockquote>\n<p>quote</p>\n</blockquote>\n<p>indented:</p>\n<blockquote>\n<p>quote</p>\n</blockquote>\n<p>no space after <code"
},
{
"path": "test/data/simple_table.html",
"chars": 975,
"preview": "<table>\n<thead>\n<tr>\n<th>header 1</th>\n<th>header 2</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>cell 1.1</td>\n<td>cell 1.2</td>"
},
{
"path": "test/data/span-level_html.html",
"chars": 184,
"preview": "<p>an <b>important</b> <a href=''>link</a></p>\n<p>broken<br/>\nline</p>\n<p><b>inline tag</b> at the beginning</p>\n<p><spa"
},
{
"path": "test/data/sparse_dense_list.html",
"chars": 73,
"preview": "<ul>\n<li>\n<p>li</p>\n</li>\n<li>\n<p>li</p>\n</li>\n<li>\n<p>li</p>\n</li>\n</ul>"
},
{
"path": "test/data/sparse_html.html",
"chars": 54,
"preview": "<div>\nline 1\n<p>line 2\nline 3</p>\n<p>line 4</p>\n</div>"
},
{
"path": "test/data/sparse_list.html",
"chars": 123,
"preview": "<ul>\n<li>\n<p>li</p>\n</li>\n<li>\n<p>li</p>\n</li>\n</ul>\n<hr />\n<ul>\n<li>\n<p>li</p>\n<ul>\n<li>indented li</li>\n</ul>\n</li>\n</"
},
{
"path": "test/data/special_characters.html",
"chars": 320,
"preview": "<p>AT&T has an ampersand in their name</p>\n<p>this & that</p>\n<p>4 < 5 and 6 > 5</p>\n<p><a href=\"http://ex"
},
{
"path": "test/data/strict_atx_heading.html",
"chars": 205,
"preview": "<h1>h1</h1>\n<h2>h2</h2>\n<h3>h3</h3>\n<h4>h4</h4>\n<h5>h5</h5>\n<h6>h6</h6>\n<p>####### not a heading</p>\n<p>#not a heading</"
},
{
"path": "test/data/strikethrough.html",
"chars": 166,
"preview": "<p><del>strikethrough</del></p>\n<p>here's <del>one</del> followed by <del>another one</del></p>\n<p>~~ this ~~ is not one"
},
{
"path": "test/data/strong_em.html",
"chars": 281,
"preview": "<p><em>em <strong>strong em</strong></em></p>\n<p><em><strong>strong em</strong> em</em></p>\n<p><em>em <strong>strong em<"
},
{
"path": "test/data/tab-indented_code_block.html",
"chars": 107,
"preview": "<pre><code><?php\n\n$message = 'Hello World!';\necho $message;\n\necho \"following a blank line\";</code></pre>"
},
{
"path": "test/data/table_inline_markdown.html",
"chars": 297,
"preview": "<table>\n<thead>\n<tr>\n<th><em>header</em> 1</th>\n<th>header 2</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><em>cell</em> 1.1</td>"
},
{
"path": "test/data/text_reference.html",
"chars": 462,
"preview": "<p><a href=\"http://example.com\">reference link</a></p>\n<p><a href=\"http://example.com\">one</a> with a semantic name</p>\n"
},
{
"path": "test/data/unordered_list.html",
"chars": 291,
"preview": "<ul>\n<li>li</li>\n<li>li</li>\n</ul>\n<p>mixed unordered markers:</p>\n<ul>\n<li>li</li>\n</ul>\n<ul>\n<li>li</li>\n</ul>\n<ul>\n<l"
},
{
"path": "test/data/untidy_table.html",
"chars": 191,
"preview": "<table>\n<thead>\n<tr>\n<th>header 1</th>\n<th>header 2</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>cell 1.1</td>\n<td>cell 1.2</td>"
},
{
"path": "test/data/url_autolinking.html",
"chars": 444,
"preview": "<p>an autolink <a href=\"http://example.com\">http://example.com</a></p>\n<p>inside of brackets [<a href=\"http://example.co"
},
{
"path": "test/data/whitespace.html",
"chars": 28,
"preview": "<pre><code>code</code></pre>"
},
{
"path": "test/data/xss_attribute_encoding.html",
"chars": 353,
"preview": "<p><a href=\"https://www.example.com"\">xss</a></p>\n<p><img src=\"https://www.example.com"\" alt=\"xss\" /></p>\n<p><"
},
{
"path": "test/data/xss_bad_url.html",
"chars": 1151,
"preview": "<p><a href=\"javascript%3Aalert(1)\">xss</a></p>\n<p><a href=\"javascript%3Aalert(1)\">xss</a></p>\n<p><a href=\"javascript%3A/"
},
{
"path": "test/data/xss_text_encoding.html",
"chars": 152,
"preview": "<p><script>alert(1)</script></p>\n<p><script></p>\n<p>alert(1)</p>\n<p></script></p>\n<p><script&"
}
]
About this extraction
This page contains the full source code of the erusev/parsedown GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 77 files (88.7 KB), approximately 27.5k tokens, and a symbol index with 92 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.