Skip to content

Close empty elements in the cleaned HTML of user guides - #4

Merged
oxixes merged 1 commit into
Ficodes:mainfrom
rafitanba:fix/clean-html-empty-elements
Oct 29, 2026
Merged

oxixes merged 1 commit into
Ficodes:mainfrom
rafitanba:fix/clean-html-empty-elements

Conversation

@rafitanba

Copy link
Copy Markdown

Summary

clean_html and filter_changelog (src/wirecloud/commons/utils/html.py) serialize the cleaned code with lxml's XML method, so an empty element is written self-closing. For example, the OpenLayers Map user guide includes <i class="fas fa-crosshairs"></i>, which is returned as <i class="fas fa-crosshairs"/>.

The frontend inserts the user guide and the changelogs with innerHTML. With the HTML parser only void elements can be self-closing, so that <i> stays open:

  • it wraps the rest of the paragraph;
  • the parser reopens it in every following list item.

The text still looks almost normal with Font Awesome, but it ends up inside the icon. A theme that gives icons a fixed size (such as the Industry theme in #2) shows the rest of the document squeezed into a one-word-wide column.

Empty non-void elements now get an explicit end tag (<i class="…"></i>). Void elements (<br/>, <img/>…) keep their current serialization.

Testing

  • New test test_clean_html_closes_empty_elements.
  • pytest tests/commons/test_commons_utils_html.py tests/catalogue/: 50 passing.
  • Checked in a local instance: the OpenLayers Map documentation renders its lists normally.

🤖 Generated with Claude Code

clean_html and filter_changelog serialize with lxml's XML method, so an
empty element such as `<i class="fas fa-crosshairs"></i>` (as used in the
OpenLayers Map user guide) became `<i class="fas fa-crosshairs"/>`. The
frontend inserts that code with innerHTML, where only void elements can be
self-closing: the <i> wrapped the rest of the paragraph and the HTML parser
reopened it in every following list item.

Give empty non-void elements an explicit end tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oxixes
oxixes merged commit 8b6d2d4 into Ficodes:main Oct 29, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants