magicbookproject / magicbook

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

Custom image directory #1

Closed shiffman closed 8 years ago

shiffman commented 8 years ago

I'm trying to sort out the best way to organize my image files. I currently have:

noc_pdf/images/intro/intro_ex01.png
noc_html/images/intro/intro_ex01.png

Then in my book I have:

<img alt="intro ex01" src="intro/intro_ex01.png" />

An in magicbook.json

         "images" : {
            "source" : "/noc_pdf/imgs/"
         }

The images show up but only if I actually write "assets" into my html source itself i.e.:

<img alt="intro ex01" src="assets/intro/intro_ex01.png" />

From what I understand magic book should add "assets" in dynamically when it generates "consolidated.html" on the way to making the PDF. But this doesn't seem to be happening.

runemadsen commented 8 years ago

Thanks! I'll take a look.

shiffman commented 8 years ago

Great, I'm sure you know this but everything is here if you want to test:

https://github.com/shiffman/The-Nature-of-Code

runemadsen commented 8 years ago

I found the bug, and will put more info here when I have pushed a fix. Also, I accidently pushed a tiny change to the NOC repo instead of the magicbook repo. I'll try to be more careful going forward, but everything should be fine.

shiffman commented 8 years ago

no worries, push away to NOC!

runemadsen commented 8 years ago

Okay, I just pushed version 0.0.18, which fixes this. There were two problems:

  1. The first (minor) problem was that you added an absolute path (/myfolder) and not a relative path (myfolder). So it couldn't find the folder, and it didn't touch the src. To fix this, I made a warning that states when the images folder is not found. It will also output a list of all local images that are not found, so it's easier to debug.
  2. The second (major) problem was that I didn't call the plugin callbacks with the plugin as this, so the settings were spilling over across builds. That is fixed now, and it was quite a good error to spot.

If you build NOC now, you'll see that the images are in the PDF. I didn't touch the HTML build settings.

shiffman commented 8 years ago

can confirm it's working, yay!