Skip to content

Commit

Permalink
Fix HeadingPermalinkProcessor skipping text contents from certain n…
Browse files Browse the repository at this point in the history
…odes (#615)
  • Loading branch information
colinodell committed May 8, 2021
1 parent 0c104b2 commit a70a586
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi

## [Unreleased][unreleased]

### Fixed

- Fixed `HeadingPermalinkProcessor` skipping text contents from certain nodes (#615)

## [1.6.0] - 2021-05-01

### Added
Expand Down
5 changes: 2 additions & 3 deletions src/Extension/HeadingPermalink/HeadingPermalinkProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
use League\CommonMark\Event\DocumentParsedEvent;
use League\CommonMark\Exception\InvalidOptionException;
use League\CommonMark\Extension\HeadingPermalink\Slug\SlugGeneratorInterface as DeprecatedSlugGeneratorInterface;
use League\CommonMark\Inline\Element\Code;
use League\CommonMark\Inline\Element\Text;
use League\CommonMark\Inline\Element\AbstractStringContainer;
use League\CommonMark\Node\Node;
use League\CommonMark\Normalizer\SlugNormalizer;
use League\CommonMark\Normalizer\TextNormalizerInterface;
Expand Down Expand Up @@ -119,7 +118,7 @@ private function getChildText(Node $node): string

$walker = $node->walker();
while ($event = $walker->next()) {
if ($event->isEntering() && (($child = $event->getNode()) instanceof Text || $child instanceof Code)) {
if ($event->isEntering() && (($child = $event->getNode()) instanceof AbstractStringContainer)) {
$text .= $child->getContent();
}
}
Expand Down

0 comments on commit a70a586

Please sign in to comment.