From 9fd3d58a35e7e0b9f9a6842d0f24571cb7fd3654 Mon Sep 17 00:00:00 2001
From: Aidan Woods
Date: Mon, 30 Dec 2019 22:32:57 +0000
Subject: [PATCH 01/17] Fix version compare
---
ParsedownExtra.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ParsedownExtra.php b/ParsedownExtra.php
index 45f4f83..ecd6aa7 100644
--- a/ParsedownExtra.php
+++ b/ParsedownExtra.php
@@ -23,7 +23,7 @@ class ParsedownExtra extends Parsedown
function __construct()
{
- if (version_compare(parent::version, '1.5.0') >= 0)
+ if (version_compare(parent::version, '1.5.0') < 0)
{
throw new Exception('ParsedownExtra requires a later version of Parsedown');
}
From 4c22769c2eb49baa996b6effb7b7943a493b65eb Mon Sep 17 00:00:00 2001
From: Aidan Woods
Date: Mon, 30 Dec 2019 22:33:20 +0000
Subject: [PATCH 02/17] Check for null parse result
---
ParsedownExtra.php | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/ParsedownExtra.php b/ParsedownExtra.php
index ecd6aa7..995ee03 100644
--- a/ParsedownExtra.php
+++ b/ParsedownExtra.php
@@ -206,6 +206,10 @@ protected function blockHeader($Line)
{
$Block = parent::blockHeader($Line);
+ if (! isset($Block)) {
+ return null;
+ }
+
if (preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
{
$attributeString = $matches[1][0];
@@ -238,6 +242,10 @@ protected function blockSetextHeader($Line, array $Block = null)
{
$Block = parent::blockSetextHeader($Line, $Block);
+ if (! isset($Block)) {
+ return null;
+ }
+
if (preg_match('/[ ]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
{
$attributeString = $matches[1][0];
@@ -302,6 +310,10 @@ protected function inlineLink($Excerpt)
{
$Link = parent::inlineLink($Excerpt);
+ if (! isset($Link)) {
+ return null;
+ }
+
$remainder = substr($Excerpt['text'], $Link['extent']);
if (preg_match('/^[ ]*{('.$this->regexAttribute.'+)}/', $remainder, $matches))
From d1208f60db969e7207348db59e819c57c3a8c9b9 Mon Sep 17 00:00:00 2001
From: Aidan Woods
Date: Mon, 30 Dec 2019 22:35:34 +0000
Subject: [PATCH 03/17] Utilise optional rawHtml to permit footnotes
---
ParsedownExtra.php | 4 ++--
composer.json | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ParsedownExtra.php b/ParsedownExtra.php
index 995ee03..bfea96d 100644
--- a/ParsedownExtra.php
+++ b/ParsedownExtra.php
@@ -23,7 +23,7 @@ class ParsedownExtra extends Parsedown
function __construct()
{
- if (version_compare(parent::version, '1.5.0') < 0)
+ if (version_compare(parent::version, '1.7.4') < 0)
{
throw new Exception('ParsedownExtra requires a later version of Parsedown');
}
@@ -432,7 +432,7 @@ protected function buildFootnoteElement()
$Element['text'][1]['text'] []= array(
'name' => 'li',
'attributes' => array('id' => 'fn:'.$definitionId),
- 'text' => "\n".$text."\n",
+ 'rawHtml' => "\n".$text."\n",
);
}
diff --git a/composer.json b/composer.json
index a8103e9..317d147 100644
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
}
],
"require": {
- "erusev/parsedown": "~1.4"
+ "erusev/parsedown": "^1.7.4"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35"
From d8845590c7d1c8cf93992fc66cdfc765e28de27c Mon Sep 17 00:00:00 2001
From: Aidan Woods
Date: Mon, 30 Dec 2019 23:02:40 +0000
Subject: [PATCH 04/17] Bump version for dev
---
ParsedownExtra.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ParsedownExtra.php b/ParsedownExtra.php
index 995ee03..3f9abf3 100644
--- a/ParsedownExtra.php
+++ b/ParsedownExtra.php
@@ -17,7 +17,7 @@ class ParsedownExtra extends Parsedown
{
# ~
- const version = '0.7.0';
+ const version = '0.8.1-dev';
# ~
From e9c25361cd262368e5ae6e4a3c56546448a79a0d Mon Sep 17 00:00:00 2001
From: Aidan Woods
Date: Mon, 30 Dec 2019 23:08:47 +0000
Subject: [PATCH 05/17] Drop hhvm
---
.travis.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 29bfea9..e1fd72d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,8 +13,6 @@ matrix:
- php: 7.0
- php: 7.1
- php: nightly
- - php: hhvm
- - php: hhvm-nightly
fast_finish: true
allow_failures:
- php: nightly
From ba0ae88eae1871a116707ffd0fc0433adbb80f14 Mon Sep 17 00:00:00 2001
From: Aidan Woods
Date: Mon, 30 Dec 2019 23:09:15 +0000
Subject: [PATCH 06/17] Test on modern versions of PHP
---
.travis.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index e1fd72d..d0b48f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,9 @@ matrix:
- php: 5.6
- php: 7.0
- php: 7.1
+ - php: 7.2
+ - php: 7.3
+ - php: 7.4
- php: nightly
fast_finish: true
allow_failures:
From 91ac3ff98f0cea243bdccc688df43810f044dcef Mon Sep 17 00:00:00 2001
From: Aidan Woods
Date: Mon, 30 Dec 2019 23:20:37 +0000
Subject: [PATCH 07/17] Bump version for release
---
ParsedownExtra.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ParsedownExtra.php b/ParsedownExtra.php
index c6a71e6..632ba84 100644
--- a/ParsedownExtra.php
+++ b/ParsedownExtra.php
@@ -17,7 +17,7 @@ class ParsedownExtra extends Parsedown
{
# ~
- const version = '0.8.1-dev';
+ const version = '0.8.1';
# ~
From decb9676ab64cc5295a8ca5dcf68170930a294ce Mon Sep 17 00:00:00 2001
From: davidbyoung
Date: Wed, 16 Oct 2024 20:03:30 -0500
Subject: [PATCH 08/17] Added GitHub CI, updated dependencies, fixed PHP 8.4
deprecations
---
.github/workflows/unit-tests.yaml | 37 ++++
.gitignore | 3 +
.travis.yml | 30 ----
ParsedownExtra.php | 272 +++++++++++++++++++++++-------
composer.json | 13 +-
phpunit.xml.dist | 2 +-
test/ParsedownExtraTest.php | 56 ++++++
7 files changed, 316 insertions(+), 97 deletions(-)
create mode 100644 .github/workflows/unit-tests.yaml
create mode 100644 .gitignore
delete mode 100644 .travis.yml
diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml
new file mode 100644
index 0000000..7956bc7
--- /dev/null
+++ b/.github/workflows/unit-tests.yaml
@@ -0,0 +1,37 @@
+on:
+ - push
+ - pull_request
+
+jobs:
+ phpunit:
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ php:
+ - '7.1'
+ - '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 vendor/erusev/parsedown/test/CommonMarkTestWeak.php || true
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ba39b9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+.phpunit.result.cache
+composer.lock
+vendor/
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index d0b48f8..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-language: php
-
-dist: trusty
-sudo: false
-
-matrix:
- include:
- - php: 5.3
- dist: precise
- - php: 5.4
- - php: 5.5
- - php: 5.6
- - php: 7.0
- - php: 7.1
- - php: 7.2
- - php: 7.3
- - php: 7.4
- - php: nightly
- fast_finish: true
- allow_failures:
- - php: nightly
- - php: hhvm-nightly
-
-install:
- - composer install --prefer-source
-
-script:
- - vendor/bin/phpunit
- - vendor/bin/phpunit vendor/erusev/parsedown/test/CommonMarkTestWeak.php || true
- - '[ -z "$TRAVIS_TAG" ] || [ "$TRAVIS_TAG" == "$(php -r "require(\"ParsedownExtra.php\"); echo ParsedownExtra::version;")" ]'
diff --git a/ParsedownExtra.php b/ParsedownExtra.php
index 632ba84..d192e2b 100644
--- a/ParsedownExtra.php
+++ b/ParsedownExtra.php
@@ -17,13 +17,13 @@ class ParsedownExtra extends Parsedown
{
# ~
- const version = '0.8.1';
+ const version = '0.8.0';
# ~
function __construct()
{
- if (version_compare(parent::version, '1.7.4') < 0)
+ if (version_compare(parent::version, '1.7.1') < 0)
{
throw new Exception('ParsedownExtra requires a later version of Parsedown');
}
@@ -43,7 +43,13 @@ function __construct()
function text($text)
{
- $markup = parent::text($text);
+ $Elements = $this->textElements($text);
+
+ # convert to markup
+ $markup = $this->elements($Elements);
+
+ # trim line breaks
+ $markup = trim($markup, "\n");
# merge consecutive dl elements
@@ -139,25 +145,27 @@ protected function blockFootnoteComplete($Block)
protected function blockDefinitionList($Line, $Block)
{
- if ( ! isset($Block) or isset($Block['type']))
+ if ( ! isset($Block) or $Block['type'] !== 'Paragraph')
{
return;
}
$Element = array(
'name' => 'dl',
- 'handler' => 'elements',
- 'text' => array(),
+ 'elements' => array(),
);
- $terms = explode("\n", $Block['element']['text']);
+ $terms = explode("\n", $Block['element']['handler']['argument']);
foreach ($terms as $term)
{
- $Element['text'] []= array(
+ $Element['elements'] []= array(
'name' => 'dt',
- 'handler' => 'line',
- 'text' => $term,
+ 'handler' => array(
+ 'function' => 'lineElements',
+ 'argument' => $term,
+ 'destination' => 'elements'
+ ),
);
}
@@ -185,15 +193,17 @@ protected function blockDefinitionListContinue($Line, array $Block)
if (isset($Block['interrupted']))
{
- $Block['dd']['handler'] = 'text';
- $Block['dd']['text'] .= "\n\n";
+ $Block['dd']['handler']['function'] = 'textElements';
+ $Block['dd']['handler']['argument'] .= "\n\n";
+
+ $Block['dd']['handler']['destination'] = 'elements';
unset($Block['interrupted']);
}
$text = substr($Line['body'], min($Line['indent'], 4));
- $Block['dd']['text'] .= "\n" . $text;
+ $Block['dd']['handler']['argument'] .= "\n" . $text;
return $Block;
}
@@ -206,17 +216,13 @@ protected function blockHeader($Line)
{
$Block = parent::blockHeader($Line);
- if (! isset($Block)) {
- return null;
- }
-
- if (preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
+ if ($Block !== null && preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['handler']['argument'], $matches, PREG_OFFSET_CAPTURE))
{
$attributeString = $matches[1][0];
$Block['element']['attributes'] = $this->parseAttributeData($attributeString);
- $Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
+ $Block['element']['handler']['argument'] = substr($Block['element']['handler']['argument'], 0, $matches[0][1]);
}
return $Block;
@@ -225,11 +231,98 @@ protected function blockHeader($Line)
#
# Markup
+ protected function blockMarkup($Line)
+ {
+ if ($this->markupEscaped or $this->safeMode)
+ {
+ return;
+ }
+
+ if (preg_match('/^<(\w[\w-]*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
+ {
+ $element = strtolower($matches[1]);
+
+ if (in_array($element, $this->textLevelElements))
+ {
+ return;
+ }
+
+ $Block = array(
+ 'name' => $matches[1],
+ 'depth' => 0,
+ 'element' => array(
+ 'rawHtml' => $Line['text'],
+ 'autobreak' => true,
+ ),
+ );
+
+ $length = strlen($matches[0]);
+ $remainder = substr($Line['text'], $length);
+
+ if (trim($remainder) === '')
+ {
+ if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
+ {
+ $Block['closed'] = true;
+ $Block['void'] = true;
+ }
+ }
+ else
+ {
+ if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
+ {
+ return;
+ }
+ if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
+ {
+ $Block['closed'] = true;
+ }
+ }
+
+ return $Block;
+ }
+ }
+
+ protected function blockMarkupContinue($Line, array $Block)
+ {
+ if (isset($Block['closed']))
+ {
+ return;
+ }
+
+ if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
+ {
+ $Block['depth'] ++;
+ }
+
+ if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
+ {
+ if ($Block['depth'] > 0)
+ {
+ $Block['depth'] --;
+ }
+ else
+ {
+ $Block['closed'] = true;
+ }
+ }
+
+ if (isset($Block['interrupted']))
+ {
+ $Block['element']['rawHtml'] .= "\n";
+ unset($Block['interrupted']);
+ }
+
+ $Block['element']['rawHtml'] .= "\n".$Line['body'];
+
+ return $Block;
+ }
+
protected function blockMarkupComplete($Block)
{
if ( ! isset($Block['void']))
{
- $Block['markup'] = $this->processTag($Block['markup']);
+ $Block['element']['rawHtml'] = $this->processTag($Block['element']['rawHtml']);
}
return $Block;
@@ -238,21 +331,17 @@ protected function blockMarkupComplete($Block)
#
# Setext
- protected function blockSetextHeader($Line, array $Block = null)
+ protected function blockSetextHeader($Line, ?array $Block = null)
{
$Block = parent::blockSetextHeader($Line, $Block);
- if (! isset($Block)) {
- return null;
- }
-
- if (preg_match('/[ ]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['text'], $matches, PREG_OFFSET_CAPTURE))
+ if ($Block !== null && preg_match('/[ ]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['handler']['argument'], $matches, PREG_OFFSET_CAPTURE))
{
$attributeString = $matches[1][0];
$Block['element']['attributes'] = $this->parseAttributeData($attributeString);
- $Block['element']['text'] = substr($Block['element']['text'], 0, $matches[0][1]);
+ $Block['element']['handler']['argument'] = substr($Block['element']['handler']['argument'], 0, $matches[0][1]);
}
return $Block;
@@ -286,8 +375,7 @@ protected function inlineFootnoteMarker($Excerpt)
$Element = array(
'name' => 'sup',
'attributes' => array('id' => 'fnref'.$this->DefinitionData['Footnote'][$name]['count'].':'.$name),
- 'handler' => 'element',
- 'text' => array(
+ 'element' => array(
'name' => 'a',
'attributes' => array('href' => '#fn:'.$name, 'class' => 'footnote-ref'),
'text' => $this->DefinitionData['Footnote'][$name]['number'],
@@ -310,11 +398,7 @@ protected function inlineLink($Excerpt)
{
$Link = parent::inlineLink($Excerpt);
- if (! isset($Link)) {
- return null;
- }
-
- $remainder = substr($Excerpt['text'], $Link['extent']);
+ $remainder = $Link !== null ? substr($Excerpt['text'], $Link['extent']) : '';
if (preg_match('/^[ ]*{('.$this->regexAttribute.'+)}/', $remainder, $matches))
{
@@ -330,21 +414,52 @@ protected function inlineLink($Excerpt)
# ~
#
- protected function unmarkedText($text)
+ private $currentAbreviation;
+ private $currentMeaning;
+
+ protected function insertAbreviation(array $Element)
{
- $text = parent::unmarkedText($text);
+ if (isset($Element['text']))
+ {
+ $Element['elements'] = self::pregReplaceElements(
+ '/\b'.preg_quote($this->currentAbreviation, '/').'\b/',
+ array(
+ array(
+ 'name' => 'abbr',
+ 'attributes' => array(
+ 'title' => $this->currentMeaning,
+ ),
+ 'text' => $this->currentAbreviation,
+ )
+ ),
+ $Element['text']
+ );
+
+ unset($Element['text']);
+ }
+
+ return $Element;
+ }
+
+ protected function inlineText($text)
+ {
+ $Inline = parent::inlineText($text);
if (isset($this->DefinitionData['Abbreviation']))
{
foreach ($this->DefinitionData['Abbreviation'] as $abbreviation => $meaning)
{
- $pattern = '/\b'.preg_quote($abbreviation, '/').'\b/';
+ $this->currentAbreviation = $abbreviation;
+ $this->currentMeaning = $meaning;
- $text = preg_replace($pattern, ''.$abbreviation.'', $text);
+ $Inline['element'] = $this->elementApplyRecursiveDepthFirst(
+ array($this, 'insertAbreviation'),
+ $Inline['element']
+ );
}
}
- return $text;
+ return $Inline;
}
#
@@ -360,18 +475,21 @@ protected function addDdElement(array $Line, array $Block)
$Block['dd'] = array(
'name' => 'dd',
- 'handler' => 'line',
- 'text' => $text,
+ 'handler' => array(
+ 'function' => 'lineElements',
+ 'argument' => $text,
+ 'destination' => 'elements'
+ ),
);
if (isset($Block['interrupted']))
{
- $Block['dd']['handler'] = 'text';
+ $Block['dd']['handler']['function'] = 'textElements';
unset($Block['interrupted']);
}
- $Block['element']['text'] []= & $Block['dd'];
+ $Block['element']['elements'] []= & $Block['dd'];
return $Block;
}
@@ -381,15 +499,11 @@ protected function buildFootnoteElement()
$Element = array(
'name' => 'div',
'attributes' => array('class' => 'footnotes'),
- 'handler' => 'elements',
- 'text' => array(
- array(
- 'name' => 'hr',
- ),
+ 'elements' => array(
+ array('name' => 'hr'),
array(
'name' => 'ol',
- 'handler' => 'elements',
- 'text' => array(),
+ 'elements' => array(),
),
),
);
@@ -405,34 +519,68 @@ protected function buildFootnoteElement()
$text = $DefinitionData['text'];
- $text = parent::text($text);
+ $textElements = parent::textElements($text);
$numbers = range(1, $DefinitionData['count']);
- $backLinksMarkup = '';
+ $backLinkElements = array();
foreach ($numbers as $number)
{
- $backLinksMarkup .= ' ';
+ $backLinkElements[] = array('text' => ' ');
+ $backLinkElements[] = array(
+ 'name' => 'a',
+ 'attributes' => array(
+ 'href' => "#fnref$number:$definitionId",
+ 'rev' => 'footnote',
+ 'class' => 'footnote-backref',
+ ),
+ 'rawHtml' => '↩',
+ 'allowRawHtmlInSafeMode' => true,
+ 'autobreak' => false,
+ );
}
- $backLinksMarkup = substr($backLinksMarkup, 1);
+ unset($backLinkElements[0]);
- if (substr($text, - 4) === '
')
- {
- $backLinksMarkup = ' '.$backLinksMarkup;
+ $n = count($textElements) -1;
- $text = substr_replace($text, $backLinksMarkup.'', - 4);
+ if ($textElements[$n]['name'] === 'p')
+ {
+ $backLinkElements = array_merge(
+ array(
+ array(
+ 'rawHtml' => ' ',
+ 'allowRawHtmlInSafeMode' => true,
+ ),
+ ),
+ $backLinkElements
+ );
+
+ unset($textElements[$n]['name']);
+
+ $textElements[$n] = array(
+ 'name' => 'p',
+ 'elements' => array_merge(
+ array($textElements[$n]),
+ $backLinkElements
+ ),
+ );
}
else
{
- $text .= "\n".''.$backLinksMarkup.'
';
+ $textElements[] = array(
+ 'name' => 'p',
+ 'elements' => $backLinkElements
+ );
}
- $Element['text'][1]['text'] []= array(
+ $Element['elements'][1]['elements'] []= array(
'name' => 'li',
'attributes' => array('id' => 'fn:'.$definitionId),
- 'rawHtml' => "\n".$text."\n",
+ 'elements' => array_merge(
+ $textElements
+ ),
);
}
@@ -535,4 +683,4 @@ protected function sortFootnotes($A, $B) # callback
#
protected $regexAttribute = '(?:[#.][-\w]+[ ]*)';
-}
+}
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 317d147..7161c96 100644
--- a/composer.json
+++ b/composer.json
@@ -9,17 +9,22 @@
{
"name": "Emanuil Rusev",
"email": "hello@erusev.com",
- "homepage": "http://erusev.com"
+ "homepage": "https://erusev.com"
}
],
"require": {
- "erusev/parsedown": "^1.7.4"
+ "erusev/parsedown": "1.8.x-dev",
+ "ext-dom": "*",
+ "ext-libxml": "*",
+ "ext-mbstring": "*"
},
"require-dev": {
- "phpunit/phpunit": "^4.8.35"
+ "phpunit/phpunit": "^7.5|^8.5|^9.6"
},
"autoload": {
- "psr-0": {"ParsedownExtra": ""}
+ "psr-0": {
+ "ParsedownExtra": ""
+ }
},
"autoload-dev": {
"psr-0": {
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 29880b5..41b4555 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,7 +1,7 @@
-
+
test/ParsedownExtraTest.php
diff --git a/test/ParsedownExtraTest.php b/test/ParsedownExtraTest.php
index d2a6d23..f4c57ff 100644
--- a/test/ParsedownExtraTest.php
+++ b/test/ParsedownExtraTest.php
@@ -8,4 +8,60 @@ protected function initDirs()
$dirs[] = __DIR__ . '/data/';
return $dirs;
}
+
+ function data()
+ {
+ $data = array();
+
+ foreach ($this->initDirs() as $i => $dir)
+ {
+ $newData = $this->dataFromDirectory($dir);
+
+ if ($i < 1)
+ {
+ # Parsedown-Extra has different treatment of HTML
+ $newData = array_filter($newData, function ($s) { return strpos($s[0], 'markup') === false; });
+ $newData = array_filter($newData, function ($s) { return strpos($s[0], 'html') === false; });
+ }
+
+ $data = array_merge($data, $newData);
+ }
+
+ return $data;
+ }
+
+ function dataFromDirectory($dir)
+ {
+ $data = array();
+
+ $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;
+ }
}
From 5c54c25c007e6658cf7413029200cfd3b1ac8600 Mon Sep 17 00:00:00 2001
From: davidbyoung
Date: Wed, 16 Oct 2024 20:11:38 -0500
Subject: [PATCH 09/17] Fixed broken data file
---
test/data/definition_list.html | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/test/data/definition_list.html b/test/data/definition_list.html
index 2567dc1..fb9b88d 100644
--- a/test/data/definition_list.html
+++ b/test/data/definition_list.html
@@ -4,14 +4,20 @@
two
extra line
Term 2
-lazy
-line
-multiple
-paragraphs
-nested
+
+lazy
+line
+
+
+multiple
+paragraphs
+
+
+nested
code block
quote
block
-
+
+
\ No newline at end of file
From 724c586e6185070bda8d46bdd0bd5dc29e47b2e1 Mon Sep 17 00:00:00 2001
From: davidbyoung
Date: Wed, 16 Oct 2024 20:23:56 -0500
Subject: [PATCH 10/17] Ignored IDE settings file
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 3d34031..ce66c0e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.idea/
.phpunit.result.cache
composer.lock
vendor/
\ No newline at end of file
From c92bf903f9ea71971ab6d6944d5f04745ac11220 Mon Sep 17 00:00:00 2001
From: davidbyoung
Date: Wed, 16 Oct 2024 20:37:49 -0500
Subject: [PATCH 11/17] Trying to fix CI
---
.github/workflows/unit-tests.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml
index 7956bc7..a0bda52 100644
--- a/.github/workflows/unit-tests.yaml
+++ b/.github/workflows/unit-tests.yaml
@@ -29,7 +29,7 @@ jobs:
php-version: '${{ matrix.php }}'
- name: Install dependencies
- run: composer install
+ run: composer install --prefer-dist --no-interaction
- name: Run tests
run: |
From 25b3fbcd32f7a9510677d308cd227babce5f52cb Mon Sep 17 00:00:00 2001
From: davidbyoung
Date: Wed, 16 Oct 2024 20:40:25 -0500
Subject: [PATCH 12/17] Trying to fix CI
---
.github/workflows/unit-tests.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml
index a0bda52..f33f726 100644
--- a/.github/workflows/unit-tests.yaml
+++ b/.github/workflows/unit-tests.yaml
@@ -29,7 +29,9 @@ jobs:
php-version: '${{ matrix.php }}'
- name: Install dependencies
- run: composer install --prefer-dist --no-interaction
+ run: |
+ composer install --prefer-dist --no-interaction
+ composer dump-autoload --optimize
- name: Run tests
run: |
From 0c8df8490937feef033782949aaf3e88ca1689a7 Mon Sep 17 00:00:00 2001
From: davidbyoung
Date: Wed, 16 Oct 2024 20:41:28 -0500
Subject: [PATCH 13/17] Trying to fix CI
---
.github/workflows/unit-tests.yaml | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml
index f33f726..d694466 100644
--- a/.github/workflows/unit-tests.yaml
+++ b/.github/workflows/unit-tests.yaml
@@ -29,11 +29,8 @@ jobs:
php-version: '${{ matrix.php }}'
- name: Install dependencies
- run: |
- composer install --prefer-dist --no-interaction
- composer dump-autoload --optimize
+ run: composer install --prefer-dist --no-interaction
- name: Run tests
run: |
- vendor/bin/phpunit
- vendor/bin/phpunit vendor/erusev/parsedown/test/CommonMarkTestWeak.php || true
\ No newline at end of file
+ vendor/bin/phpunit
\ No newline at end of file
From 4d62bd425c5fd14ca4a3d133f6cfc824b117a8ec Mon Sep 17 00:00:00 2001
From: davidbyoung
Date: Wed, 16 Oct 2024 20:47:07 -0500
Subject: [PATCH 14/17] Trying to fix CI
---
.github/workflows/unit-tests.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml
index d694466..870dcae 100644
--- a/.github/workflows/unit-tests.yaml
+++ b/.github/workflows/unit-tests.yaml
@@ -33,4 +33,5 @@ jobs:
- name: Run tests
run: |
+ ls -al vendor/erusev/parsedown
vendor/bin/phpunit
\ No newline at end of file
From 6525d04b5cf664100929179bf97def689fc461eb Mon Sep 17 00:00:00 2001
From: davidbyoung
Date: Wed, 16 Oct 2024 20:48:42 -0500
Subject: [PATCH 15/17] Trying to fix CI
---
.github/workflows/unit-tests.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml
index 870dcae..ba541d0 100644
--- a/.github/workflows/unit-tests.yaml
+++ b/.github/workflows/unit-tests.yaml
@@ -29,7 +29,7 @@ jobs:
php-version: '${{ matrix.php }}'
- name: Install dependencies
- run: composer install --prefer-dist --no-interaction
+ run: composer install --prefer-source --no-interaction
- name: Run tests
run: |
From b56e466bc639bda938d824ec33e1d5e1fd094e56 Mon Sep 17 00:00:00 2001
From: davidbyoung
Date: Wed, 16 Oct 2024 22:08:00 -0500
Subject: [PATCH 16/17] Removed debugging step from CI
---
.github/workflows/unit-tests.yaml | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml
index ba541d0..97f8e33 100644
--- a/.github/workflows/unit-tests.yaml
+++ b/.github/workflows/unit-tests.yaml
@@ -32,6 +32,4 @@ jobs:
run: composer install --prefer-source --no-interaction
- name: Run tests
- run: |
- ls -al vendor/erusev/parsedown
- vendor/bin/phpunit
\ No newline at end of file
+ run: vendor/bin/phpunit
\ No newline at end of file
From b000c295f04c2af4e29ad7fa5dba093a0fa5c52d Mon Sep 17 00:00:00 2001
From: davidbyoung
Date: Sat, 2 Nov 2024 16:21:17 -0500
Subject: [PATCH 17/17] Removed .idea from .gitignore, updated to use
dev-master of Parsedown
---
.gitignore | 1 -
composer.json | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index ce66c0e..3d34031 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
-.idea/
.phpunit.result.cache
composer.lock
vendor/
\ No newline at end of file
diff --git a/composer.json b/composer.json
index c9ce11d..84bf8f6 100644
--- a/composer.json
+++ b/composer.json
@@ -13,7 +13,7 @@
}
],
"require": {
- "erusev/parsedown": "1.8.x-dev",
+ "erusev/parsedown": "dev-master",
"ext-dom": "*",
"ext-libxml": "*",
"ext-mbstring": "*",