Skip to content

Releases: BenjaminHoegh/ParsedownToc

v1.6.0

27 Apr 15:14

Choose a tag to compare

Added

  • Support for Parsedown 1.8

    • Compatible with Parsedown 1.7.4+ and 1.8.x
    • Minimum required version remains 1.7.4
  • New anchor_prefix option

    • Prepends a string to all generated anchor IDs
    • Default: ''
    • Set via setTocAnchorPrefix(string $prefix)

Changed

Renamed options (with deprecations)

The following option keys have been renamed for clarity. Old keys still work via setOptions() but trigger E_USER_DEPRECATED.

Deprecated New
blacklist reserved_ids
url base_url
limit max_anchor_length

Renamed methods (with deprecations)

The following methods are deprecated and will be removed in a future release:

Deprecated method Replacement
setTocBlacklist(array $blacklist) setTocReservedIds(array $reservedIds)
setTocUrl(string $url) setTocBaseUrl(string $url)
setTocLimit(?int $limit) setTocMaxAnchorLength(?int $length)

All deprecated methods trigger E_USER_DEPRECATED and internally delegate to their replacements.


Fixed

  • Empty anchor IDs for symbol-only headings

    • Headings like ### --- or ### © no longer produce empty IDs
    • Fallback now uses section, with deduplication (section-1, section-2, ...)
  • Invalid limit values

    • setTocLimit() now throws InvalidArgumentException for 0 or negative values
    • Prevents unintended empty anchor IDs
  • Duplicate anchor suffix delimiter

    • Now respects configured delimiter instead of always using -
  • Incorrect error location in contentsList()

    • Error messages now correctly reference the caller
    • Backtrace limited to relevant frames
  • Empty headings in ToC

    • Anchor IDs are no longer generated for completely empty headings

Deprecations

  • Old option keys and methods are deprecated
  • They will be removed in a future release
  • Update to the new names to avoid E_USER_DEPRECATED notices

v1.5.5

25 Apr 18:30

Choose a tag to compare

Security

Previously, the generated ToC was first built as a Markdown list and then passed back through Parsedown for HTML rendering. In this release, the ToC is rendered directly as escaped HTML from the collected heading data.
This reduces the risk of unsafe Markdown/HTML interpretation from heading text, generated IDs, and ToC link values.

What's Changed

  • Reworked ToC HTML generation to render directly from the internal contents list.
  • Removed the legacy intermediate Markdown-list rendering step for contentsList('html') and contentsList('string').
  • Escaped ToC link text using htmlspecialchars().
  • Escaped ToC link href attributes using htmlspecialchars().
  • Escaped the ToC container id attribute.
  • Refactor attribute assignment for heading IDs by @ArnaudLigny in #28

Full Changelog: v1.5.4...v1.5.5

v1.5.4

14 Jul 04:57
5495e00

Choose a tag to compare

What's Changed

Full Changelog: v1.5.3...v1.5.4

v1.5.3 Release - Hotfix

03 Feb 19:41

Choose a tag to compare

What's Changed

  • Fixes a bug where uniquifyAnchorID didn't keep track of anchors
  • Fixes a bug where headings still generated toc data for disabled levels

Full Changelog: v1.5.2...v1.5.3

v1.5.2

02 Feb 21:45

Choose a tag to compare

What's Changed

  • Code quality improvements
  • Added option for custom logic for anchors.
  • Added back transliterate, was missing, whoops
  • Added PHP version check
  • Fixed a deprecation issue in php 8

Full Changelog: 1.5.1...v1.5.2

1.5.1 Hotfix

16 Aug 07:23
7fa5c8e

Choose a tag to compare

What's Changed

Full Changelog: 1.5...1.5.1

1.5

13 Aug 06:02
7dc0e82

Choose a tag to compare

1.5

Added:

  1. Introduced a new method setOptions($options) to allow users to update or set new configurations for the parser.
  2. Explicit declaration for the $options property to ensure compatibility with PHP 8.2's deprecation of dynamic properties.
  3. Added setters for each option

Modified:

  1. Updated the __construct() method to initialize default options.
  2. Replaced DynamicClass to a new class alias ParsedownExtendedParentAlias to refer to the parent class, either ParsedownExtra or Parsedown, based on their availability. Thanks to @raffaelj #15
  3. Enhanced the createAnchorID method:
    • Integrated the iconv function for transliteration of header text to ASCII.
  4. Changed Transliterate to use the PHP build-in iconv

1.4.3

18 Jan 11:23
31550a0

Choose a tag to compare

What's Changed

  • fix: Using ${var} in strings is deprecated by @pjbakker in #11

1.4.2

25 Oct 07:58
cf79902

Choose a tag to compare

Option to prefix anchor with an URL #10

1.4.1

24 Nov 13:21
2576c43

Choose a tag to compare

fix: phpdoc of text() function #8