hagenburger / pimd

PIMD – Processing Instructions for Markdown
https://hagenburger.github.io/pimd-docs/
MIT License
20 stars 5 forks source link

Automatically generate IDs for code examples #26

Open hagenburger opened 6 years ago

hagenburger commented 6 years ago

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](../../tree/master/plugins/ids) is used:

``` html
<div class="pimd-example" id="my-id">
...

When no ID is defined:

``` html
<p>Lorem ipsum</p>

It should get an automatically generated ID:

``` html
<div class="pimd-example" id="example-f2d69d">
...

Open questions

12finger commented 6 years ago
  • 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

hagenburger commented 6 years ago

@12finger yes, go with it as suggested.

violetadev commented 6 years ago

#26 Automatically generate IDs for code examples