Automatically generate IDs for code examples
Opened this issue · 3 comments
hagenburger commented
New feature
Code examples should get an automatically generated HTML ID if not defined by the user.
Specification
``` html #my-id
<p>Lorem ipsum</p>
```
Already gets the ID my-id
when the ID plugin is used:
<div class="pimd-example" id="my-id">
...
When no ID is defined:
``` html
<p>Lorem ipsum</p>
```
It should get an automatically generated ID:
<div class="pimd-example" id="example-f2d69d">
...
Open questions
- How to generate the ID? Maybe generate a hash of the contents
- How long should the ID be? Maybe 6 hex characters should be enough
12finger commented
- How to generate the ID? Maybe generate a hash of the contents
I agree, would be nice to get this working!
- How long should the ID be? Maybe 6 hex characters should be enough
as inspiration i would start looking into the code of css-modules as they do similar things with their classes.
along these lines?
example:
https://www.javascriptstuff.com/css-modules-by-example/
hagenburger commented
@12finger yes, go with it as suggested.