hagenburger/pimd

Automatically generate IDs for code examples

Opened this issue · 3 comments

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
  • 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/

see:
css modules by example 2018-08-21 14-06-38

@12finger yes, go with it as suggested.