Skip to main content

Overview

Removes anchor and hadeeth tags from the content while preserving <span> elements. This is useful for cleaning Shamela HTML while maintaining the title hierarchy information stored in span tags.

Signature

Parameters

string
required
HTML string containing various tags

Returns

string
The content with only span tags retained

Tags Removed

Anchor Tags (<a>)

  • Removes <a> tags but preserves the text content inside
  • Pattern: /<a[^>]*>(.*?)<\/a>/gs
  • Example: <a href="inr://123">text</a> → text

Hadeeth Tags

  • Removes all hadeeth-related tags:
    • Self-closing: <hadeeth />
    • With content: <hadeeth>...</hadeeth>
    • Numbered: <hadeeth-1>, <hadeeth-2>, etc.
  • Pattern: /<hadeeth[^>]*>|<\/hadeeth>|<hadeeth-\d+>/gs

Example

Use Cases

Preserve Title Hierarchy

Prepare for Display

Processing Pipeline

Recommended order when processing Shamela content:

Complete Tag Removal

If you need to remove ALL tags including spans, use stripHtmlTags() instead: