php-textile icon indicating copy to clipboard operation
php-textile copied to clipboard

Auto-generate header id attribute from its contents

Open eliph opened this issue 3 years ago • 2 comments

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

eliph avatar Feb 28 '21 11:02 eliph

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.

wion avatar Feb 28 '21 16:02 wion

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>

eliph avatar Feb 28 '21 16:02 eliph