Skip to content

Commit

Permalink
Merge branch 'release/3.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed May 8, 2023
2 parents fc6a855 + 53b469e commit 7aec879
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v3.2.1
## 05/08/2023

1. [](#improved)
* Fixed a "Deprecated: mb_convert_encoding()" error

# v3.2.0
## 02/23/2022

Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ user/themes/quark/templates/components/page-toc.html.twig

NOTE: It's not required to set the TOC plugin `active` if you use the shortcode syntax in your content. That is a good enough indication that you want the plugin to be active.

### Customizing specific anchors

There are situations where you want to have absolute control over the exact anchor link rather than letting page-toc create one for you. The best way to achieve this is to add your own `id` attribute to the header tag. This can be done either via HTML in your markdown directly:

```html
<h2 id="my-custom-anchor">H2 Header</h2>
```

Or via using the header shortcodes. This approach is particularly useful if you have markdown inside your header tag:

```markdown
[h2 id="my-custom-anchor"]H2 _header_[/h2]
```

If an `id` is found in one of the header tags that page-toc is configured to use for anchors, then it will use the provided value for the anchor id.

### Anchor Shortcode

Page TOC now includes a `anchor` shortcode that allows you to manually add linkable fragments in your content.
Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Page Toc
type: plugin
slug: page-toc
version: 3.2.0
version: 3.2.1
description: Generate a table of contents and anchors from a page
icon: list
author:
Expand Down
3 changes: 2 additions & 1 deletion classes/HtmlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ protected function getHTMLParser($markup)
{
libxml_use_internal_errors(true);
$domDocument = new \DOMDocument();
$domDocument->loadHTML(mb_convert_encoding("<page-toc>$markup</page-toc>", 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$html = htmlspecialchars_decode(iconv('UTF-8', 'ISO-8859-1', htmlentities("<page-toc>$markup</page-toc>", ENT_COMPAT, 'UTF-8')), ENT_QUOTES);
$domDocument->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$domDocument->preserveWhiteSpace = true;
return $domDocument;
}
Expand Down

0 comments on commit 7aec879

Please sign in to comment.