Skip to content

Add an ID blacklist for Heading Permalink extension #1080

Open
@nicholasbrantley

Description

@nicholasbrantley

Description

It would be nice if there was an option to have a blacklist of HTML IDs that should be considered "already used" when generating the anchor IDs. These would be handled like they were a duplicate heading where the count is appended to it.

This would be an alternative to having to use id_prefix and prepending something to all the IDs, that way they can look normal besides the blacklisted ones.

Example

Have an array for the config:

$config = [
    'heading_permalink' => [
        'id_blacklist' => ['example-id', 'another-example'],
    ],
];

Then if you have headings that generate an ID that matches one in the list:

## Example ID

...

## Another Example

...

## Another Example 

...

...it would generate the IDs as if they were already used:

<h2>Example ID <a id="example-id-1" href="#example-id-1"></h2>

...

<h2>Another Example <a id="another-example-1" href="#another-example-1"></h2>

...

<h2>Another Example <a id="another-example-2" href="#another-example-2"></h2>

...

Did this project help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew functionality or behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions