php-textile
php-textile copied to clipboard
Auto-generate header id attribute from its contents
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
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.
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>