Skip to content

Feature Request: Flexible Text Extraction from Headers Excluding Specific Tags #17

@0xMax42

Description

@0xMax42

Description

Background

The current implementation of the Table of Contents (TOC) plugin for PicoCMS extracts text from headers (e.g., <h1>, <h2>) for generating a TOC. However, it does not provide a way to exclude specific HTML tags (like <sup> tags used for footnotes) from these headers. In our use case, footnotes are included in headers, but they should not appear in the TOC entries.

Problem

When the TOC is generated, all contents within the header tags, including <sup> tags and their children, are included. This results in unwanted footnote references appearing in the TOC, which is not desirable for readability and format consistency.

Proposed Feature

I propose a feature enhancement to the TOC plugin that allows specifying an array of tags (e.g., ['sup', 'script', 'style']) to be excluded from the text extraction process when generating the TOC.

Suggested Implementation

Function Enhancement

  • Enhance the existing text extraction function to accept an additional parameter: an array of tag names to ignore.
  • During text extraction, the function should skip any tags (and their children) that are listed in this array.
  • This approach offers flexibility and can be useful for other scenarios where specific tag exclusion is required.

Configuration Option (Optional)

  • Consider adding a plugin configuration option that allows users to specify the tags to be excluded.
  • This will provide end-users with customization capabilities without needing to modify the code.

Impact

  • This enhancement will increase the plugin's flexibility and usability for various use cases.
  • It minimizes changes to the existing codebase, maintaining the current functionality while extending new capabilities.

I believe this feature would be a valuable addition to the plugin, enhancing its usability for a wider range of markdown documents and use cases. Looking forward to feedback and suggestions on this proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions