Skip to content

Commit

Permalink
downgrade w2m
Browse files Browse the repository at this point in the history
  • Loading branch information
benbalter committed Apr 18, 2024
1 parent 2e46430 commit 52dec71
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 64 deletions.
14 changes: 7 additions & 7 deletions vendor/league/html-to-markdown/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
Expand All @@ -28,19 +28,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
php: ['7.2', '7.3', '7.4']
coverage: [true]
composer-flags: ['']
include:
- php: '8.2'
- php: '8.0'
coverage: false
composer-flags: '--ignore-platform-req=php'
- php: '7.2'
coverage: false
composer-flags: '--prefer-lowest'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
Expand All @@ -53,7 +53,7 @@ jobs:

- name: "Use PHPUnit 9.3+ on PHP 8"
run: composer require --no-update --dev phpunit/phpunit:^9.3
if: "matrix.php >= '8.0'"
if: "matrix.php == '8.0'"

- run: composer update --no-progress ${{ matrix.composer-flags }}

Expand All @@ -72,7 +72,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
Expand All @@ -90,7 +90,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
Expand Down
21 changes: 1 addition & 20 deletions vendor/league/html-to-markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip

## [Unreleased][unreleased]

## [5.1.1] - 2023-07-12

### Fixed

- Fixed `<pre>` tags with attributes not being parsed (#215, #238)
- Fixed missing type checks and coercions

## [5.1.0] - 2022-03-02

### Changed

- Changed horizontal rule style (#218, #219)

### Fixed

- Fixed `Element::getValue()` not handling possible nulls

## [5.0.2] - 2021-11-06

### Fixed
Expand Down Expand Up @@ -322,9 +305,7 @@ not ideally set, so this releases fixes that. Moving forwards this should reduce
### Added
- Initial release

[unreleased]: https://github.com/thephpleague/html-to-markdown/compare/5.1.1...master
[5.1.1]: https://github.com/thephpleague/html-to-markdown/compare/5.1.0...5.1.1
[5.1.0]: https://github.com/thephpleague/html-to-markdown/compare/5.0.2...5.1.0
[unreleased]: https://github.com/thephpleague/html-to-markdown/compare/5.0.2...master
[5.0.2]: https://github.com/thephpleague/html-to-markdown/compare/5.0.1...5.0.2
[5.0.1]: https://github.com/thephpleague/html-to-markdown/compare/5.0.0...5.0.1
[5.0.0]: https://github.com/thephpleague/html-to-markdown/compare/4.10.0...5.0.0
Expand Down
25 changes: 4 additions & 21 deletions vendor/league/html-to-markdown/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,16 @@
},
"require-dev": {
"mikehaertl/php-shellcommand": "^1.1.0",
"phpstan/phpstan": "^1.8.8",
"phpstan/phpstan": "^0.12.82",
"phpunit/phpunit": "^8.5 || ^9.2",
"scrutinizer/ocular": "^1.6",
"unleashedtech/php-coding-standard": "^2.7 || ^3.0",
"vimeo/psalm": "^4.22 || ^5.0"
"unleashedtech/php-coding-standard": "^2.7",
"vimeo/psalm": "^4.6"
},
"bin": ["bin/html-to-markdown"],
"scripts": {
"phpcs": "phpcs",
"phpstan": "phpstan analyse",
"phpunit": "phpunit --no-coverage",
"psalm": "psalm --stats",
"test": [
"@phpcs",
"@phpstan",
"@psalm",
"@phpunit"
]
},
"extra": {
"branch-alias": {
"dev-master": "5.2-dev"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
"dev-master": "5.1-dev"
}
}
}
1 change: 1 addition & 0 deletions vendor/league/html-to-markdown/psalm.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
errorLevel="3"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class HorizontalRuleConverter implements ConverterInterface
{
public function convert(ElementInterface $element): string
{
return "---\n\n";
return "- - - - - -\n\n";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ private function isValidEmail(string $email): bool

private function shouldStrip(): bool
{
return \boolval($this->config->getOption('strip_placeholder_links') ?? false);
return $this->config->getOption('strip_placeholder_links') ?? false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace League\HTMLToMarkdown\Converter;

use League\HTMLToMarkdown\Coerce;
use League\HTMLToMarkdown\Configuration;
use League\HTMLToMarkdown\ConfigurationAwareInterface;
use League\HTMLToMarkdown\ElementInterface;
Expand Down Expand Up @@ -39,8 +38,8 @@ public function convert(ElementInterface $element): string
}

if ($listType === 'ul') {
$listItemStyle = Coerce::toString($this->config->getOption('list_item_style', '-'));
$listItemStyleAlternate = Coerce::toString($this->config->getOption('list_item_style_alternate', ''));
$listItemStyle = $this->config->getOption('list_item_style', '-');
$listItemStyleAlternate = $this->config->getOption('list_item_style_alternate');
if (! isset($this->listItemStyle)) {
$this->listItemStyle = $listItemStyleAlternate ?: $listItemStyle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class PreformattedConverter implements ConverterInterface
public function convert(ElementInterface $element): string
{
$preContent = \html_entity_decode($element->getChildrenAsString());
$preContent = \preg_replace('/<pre\b[^>]*>/', '', $preContent);
\assert($preContent !== null);
$preContent = \str_replace('</pre>', '', $preContent);
$preContent = \str_replace(['<pre>', '</pre>'], '', $preContent);

/*
* Checking for the code tag.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace League\HTMLToMarkdown\Converter;

use League\HTMLToMarkdown\Coerce;
use League\HTMLToMarkdown\Configuration;
use League\HTMLToMarkdown\ConfigurationAwareInterface;
use League\HTMLToMarkdown\ElementInterface;
Expand Down Expand Up @@ -90,7 +89,7 @@ public function convert(ElementInterface $element): string
}

$value = \str_replace("\n", ' ', $value);
$value = \str_replace('|', Coerce::toString($this->config->getOption('table_pipe_escape') ?? '\|'), $value);
$value = \str_replace('|', $this->config->getOption('table_pipe_escape') ?? '\|', $value);

return '| ' . \trim($value) . ' ';
case 'thead':
Expand Down
12 changes: 7 additions & 5 deletions vendor/league/html-to-markdown/src/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getTagName(): string

public function getValue(): string
{
return $this->node->nodeValue ?? '';
return $this->node->nodeValue;
}

public function hasParent(): bool
Expand Down Expand Up @@ -98,8 +98,6 @@ public function getChildren(): array
{
$ret = [];
foreach ($this->node->childNodes as $node) {
/** @psalm-suppress RedundantCondition */
\assert($node instanceof \DOMNode);
$ret[] = new self($node);
}

Expand All @@ -118,7 +116,7 @@ public function getNext(): ?ElementInterface
return $this->nextCached;
}

private function getNextNode(\DOMNode $node, bool $checkChildren = true): ?\DOMNode
private function getNextNode(\DomNode $node, bool $checkChildren = true): ?\DomNode
{
if ($checkChildren && $node->firstChild) {
return $node->firstChild;
Expand All @@ -144,7 +142,11 @@ public function isDescendantOf($tagNames): bool
$tagNames = [$tagNames];
}

for ($p = $this->node->parentNode; $p !== null; $p = $p->parentNode) {
for ($p = $this->node->parentNode; $p !== false; $p = $p->parentNode) {
if ($p === null) {
return false;
}

if (\in_array($p->nodeName, $tagNames, true)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/league/html-to-markdown/src/HtmlConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ protected function convertToMarkdown(ElementInterface $element): string
$tag = $element->getTagName();

// Strip nodes named in remove_nodes
$tagsToRemove = \explode(' ', Coerce::toString($this->getConfig()->getOption('remove_nodes') ?? ''));
$tagsToRemove = \explode(' ', $this->getConfig()->getOption('remove_nodes') ?? '');
if (\in_array($tag, $tagsToRemove, true)) {
return '';
}
Expand Down

0 comments on commit 52dec71

Please sign in to comment.