Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module provides a Twig filter that safely removes HTML tags from text, preventing words from merging together. It also offers options to preserve specific HTML tags and convert relative links to absolute URLs, making it ideal for cleaning up content for search indexes.

The Plain Search Index Filter module introduces a powerful Twig extension, strip_tags_safe, designed to enhance the rendering of search index results in Drupal by seamlessly removing unwanted HTML while preserving the spacing and integrity of text. This solution prevents word merging issues commonly seen with the standard striptags filter, making it ideal for ensuring clean, readable search results.

Features

  • Basic Functionality: The module provides a new Twig filter strip_tags_safe, which can be applied to render arrays and strings to remove all HTML tags while preventing the merging of adjacent words.
  • Unique Features: Unlike striptags, strip_tags_safe maintains spaces where HTML tags were, ensuring that words do not run together.
  • Use Cases: Ideal for sites where search indexes need clean text inputs free from HTML clutter, such as academic databases, corporate websites, and libraries.

New Features

Configuration Page

  • Added a settings page at Administration > Configuration > System > Plain Search Index Filter settings
  • Configure link now available on the Extend page for quick access

Allowed HTML Tags

  • New option to preserve specific HTML tags when stripping content
  • Add multiple tags using the "Add another tag" interface
  • Useful for keeping semantic markup like <a>, <strong>, <em> in indexed content

Convert Relative Links to Absolute URLs

  • New checkbox option to convert relative URLs to absolute
  • Converts href="https://www.drupal.org/path" and src="/path" attributes to include the full domain
  • Ideal for content being indexed by external search systems

Post-Installation

After installing the Plain Search Index Filter module:

  1. No additional configuration page is needed.
  2. Simply apply the strip_tags_safe filter within your Twig templates to sanitize output for search indexes or any other text display.
  3. Example usage in node--search-index.html.twig:
    {{% set renderContent %}
        {{ content }}
    {% endset %}
    {{ renderContent|strip_tags_safe }}
    

Additional Requirements

For more information about setting up your Search API index using rendered HTML see this page.

  • Search API: Complements search functionalities, particularly when creating custom search pages and indexes.

Similar projects

While the twig's |striptags filter performs a similar function, the Plain Search Index Filter module uniquely preserves text spacing and integrity, making it more suitable for professional and academic applications where text readability is crucial.

Activity

Total releases
3
First release
Apr 2025
Latest release
5 months ago
Releases (12 mo)
1 ▼ from 2
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.1.0 Stable Jan 28, 2026
1.0.0 Stable Apr 4, 2025
1.0.x-dev Dev Apr 2, 2025