Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Auto-generate header id attribute from its contents #213

Open
eliph opened this issue Feb 28, 2021 · 2 comments
Open

Auto-generate header id attribute from its contents #213

eliph opened this issue Feb 28, 2021 · 2 comments

Comments

@eliph
Copy link

eliph commented Feb 28, 2021

Is your feature request related to a problem?

feature request

What is the feature?

Instead of having to write

h1(#header). Header

it would be more convenient if any

h1. Header

phrase was parsed as

<h1 id="header">Header</h1>.

The reason for this request is that having an id in every header tag would enable creating a table of contents much more easily

@wion
Copy link

wion commented Feb 28, 2021

I like this idea, because I'm always forgetting to put IDs, or even just the octothorp (#), in my headers when using contents lists. But I wonder if a more concise/systematic ID pattern could be generated instead of the actual header text, which can potentially be several words in length)?

For example, hnnnnn, where nnnnn is a random-generated string of numbers?

<h1 id="h40603">Header</h1>

Or something similar. Just a thought.

On second thought, my idea is bad. I often have constant elements in my article (e.g. Preface, Endnotes, whatever) with CSS all set up and I'd not want to wreck that with random ID values. But I'm still not crazy about the potential for a really long ID value either. Don't know.

@eliph
Copy link
Author

eliph commented Feb 28, 2021

Try Pandoc. With this Textile input:

h2. NASA’s Perseverance Rover Gives High-Definition Panoramic View of Landing Site

you would get:

<h2 id="nasas-perseverance-rover-gives-high-definition-panoramic-view-of-landing-site">NASA’s Perseverance Rover Gives High-Definition Panoramic View of Landing Site</h2>

@gocom gocom changed the title Insert id= into header tags Auto-generate header id attribute from its contents May 3, 2022
@gocom gocom added this to the 3.8.0 milestone May 3, 2022
@gocom gocom modified the milestones: 3.8.0, 5.0.0 Dec 3, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants