magicbookproject / magicbook

The magic book project returns!
MIT License
1.07k stars 59 forks source link

Duplicated auto-generated IDs #8

Closed shiffman closed 8 years ago

shiffman commented 8 years ago

I'm having an error that I can't figure out. I have several instances of <data-type="tip"></div> in my book (one per chapter actually). During the build process these get turned into:

<div data-type="tip" id="the-ecosystem-project-wpBck">

I've determined that if I ever build the book with more than 5 chapters, I get an error due to a duplicated ID, like somehow the wpBck has been generated twice. I am not sure if there is a magic book bug or a bug in my markup.

I am going to investigate this more by making some dummy, test files.

shiffman commented 8 years ago

Something must be going on in my markup as this file builds no problem.

https://github.com/shiffman/The-Nature-of-Code/blob/id_bug/chapters/tip_test.html

runemadsen commented 8 years ago

Hmm, interesting. Currently, I'm generating those ID's based on the tip's position in the DOM. So maybe they all have the same position in the files? Can you post the files array I need to have to make this happen, and I'll take a look.

shiffman commented 8 years ago

As far as I can tell, any 6 chapters. For example:

https://github.com/shiffman/The-Nature-of-Code/blob/master/magicbook.json

   "files":[
      "chapters/01_vectors.html",
      "chapters/02_forces.html",
      "chapters/03_oscillation.html",
      "chapters/04_particles.html",
      "chapters/05_physicslib.html",
      "chapters/06_steering.html"
   ],
runemadsen commented 8 years ago

Great. Let me take a look and try to fix this.

runemadsen commented 8 years ago

I've just confirmed that this is a bug in the ID rendering. Fixing now.

runemadsen commented 8 years ago

Ok, this is fixed in 0.1.5. I added a test so we're sure this doesn't happen again: https://github.com/magicbookproject/magicbook/blob/master/spec/plugins/ids_spec.js#L22-L38