Skip to content

Commit

Permalink
Merge branch 'release/3.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed May 10, 2023
2 parents 7aec879 + 188ce24 commit 4818734
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v3.2.2
## 05/10/2023

1. [](#bugfix)
* Use `mb_encode_nuericentity()` instead of `htmlspecialchars` / `iconv` approach to fix breaking UTF-8 characters
* Fix a deprecated message in the Twig macro

# v3.2.1
## 05/08/2023

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.1
version: 3.2.2
description: Generate a table of contents and anchors from a page
icon: list
author:
Expand Down
4 changes: 2 additions & 2 deletions classes/HtmlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ protected function getHTMLParser($markup)
{
libxml_use_internal_errors(true);
$domDocument = new \DOMDocument();
$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);
$html = "<page-toc>$markup</page-toc>";
$domDocument->loadHTML(mb_encode_numericentity($html, [0x80, 0x10FFFF, 0, ~0], 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$domDocument->preserveWhiteSpace = true;
return $domDocument;
}
Expand Down
7 changes: 4 additions & 3 deletions templates/components/page-toc.html.twig
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{% import _self as self %}

{% macro toc_loop(items) %}
{% import _self as self %}
{% for item in items %}
{% set class = loop.first ? 'first' : loop.last ? 'last' : null %}
<li {% if class %}class="{{ class }}"{% endif %}>
<a href="{{ item.uri }}">{{ item.label }}</a>
{% if item.children|length > 0 %}
<ul>
{{ _self.toc_loop(item.children) }}
{{ self.toc_loop(item.children) }}
</ul>
{% endif %}
</li>
Expand All @@ -19,7 +20,7 @@
{% if table_of_contents is not empty %}
<h4>{{ 'PLUGIN_PAGE_TOC.TABLE_OF_CONTENTS'|t }}</h4>
<ul>
{{ _self.toc_loop(table_of_contents.children) }}
{{ self.toc_loop(table_of_contents.children) }}
</ul>
{% endif %}
</div>
Expand Down

0 comments on commit 4818734

Please sign in to comment.