Releases: BenjaminHoegh/ParsedownToc
v1.6.0
Added
-
Support for Parsedown 1.8
- Compatible with Parsedown
1.7.4+and1.8.x - Minimum required version remains
1.7.4
- Compatible with Parsedown
-
New
anchor_prefixoption- 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, ...)
- Headings like
-
Invalid
limitvaluessetTocLimit()now throwsInvalidArgumentExceptionfor0or negative values- Prevents unintended empty anchor IDs
-
Duplicate anchor suffix delimiter
- Now respects configured
delimiterinstead of always using-
- Now respects configured
-
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_DEPRECATEDnotices
v1.5.5
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
What's Changed
- Updated outdated link by @BenjaminHoegh in #23
- Update README.md by @BenjaminHoegh in #25
- More tests and small changes by @BenjaminHoegh in #24
- Fix return type of contentsList by @JiFish in #26
- fix URL option by @ArnaudLigny in #27
Full Changelog: v1.5.3...v1.5.4
v1.5.3 Release - Hotfix
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
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
What's Changed
- Fix for #18 by @raffaeljin
- Added version check for ParsedownExtra by @BenjaminHoegh in #20
Full Changelog: 1.5...1.5.1
1.5
Added:
- Introduced a new method
setOptions($options)to allow users to update or set new configurations for the parser. - Explicit declaration for the
$optionsproperty to ensure compatibility with PHP 8.2's deprecation of dynamic properties. - Added setters for each option
Modified:
- Updated the
__construct()method to initialize default options. - Replaced
DynamicClassto a new class alias ParsedownExtendedParentAlias to refer to the parent class, either ParsedownExtra or Parsedown, based on their availability. Thanks to @raffaelj #15 - Enhanced the
createAnchorIDmethod:- Integrated the
iconvfunction for transliteration of header text to ASCII.
- Integrated the
- Changed Transliterate to use the PHP build-in iconv