Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.
This repository was archived by the owner on Feb 26, 2026. It is now read-only.

expose innerText in transformer function for transformTags #703

@volodymyrbalytskyy

Description

@volodymyrbalytskyy

The problem to solve

The objective:

Go from this: <a href="http://github.com">GitHub</a>
To this: <p>GitHub <http://github.com></p>

(convert anchor tag to paragraph tag and then set paragraphs' inner content as a combination of anchor's innerText with the href attribute)

I was trying to achieve this through transformTags but noticed that there is no way to access innerText of the anchor's tag.

Proposed solution

Something like this, below the third argument is new but maybe even exposing the innerText from attribs argument would be just fine.

    transformTags: {
      a: function (_tagName: string, attribs: Attributes, text: string) {
        return {
          tagName: 'p',
          attribs: {},
          text: `${text} <${attribs.href}>`, 
        };
      },
    },

Alternatives

No alternatives in mind at this time.

Additional context

Kinda relatable: #690

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions