todvora / gitbook-plugin-image-captions

Image captions plugin for GitBook
Apache License 2.0
44 stars 18 forks source link

Image caption not working #18

Open rmshkmr opened 8 years ago

rmshkmr commented 8 years ago

I have added the following image in markdown file. <img src="ZC1001.png" title="ZC1001" alt="ZC1001">

and added the following in book.json { "plugins": [

    "image-captions"
],
"pluginsConfig": {

"image-captions": {
      "caption": "Fig - _CAPTION_"
  }
}

}

It is showing " Fig - " No Caption

todvora commented 8 years ago

Hi @rmshkmr, This is most likely due to raw HTML inserted into markdown file. The plugin parses your markdown file and expects markdown syntax, effectively ignoring any raw HTML. I'll see, what can be done in this matter.

Do you have any specific reason, why the image is inserted as raw HTML instead of markdown syntax for images? If not, could you insert the image in following form?

![ZC1001](ZC1001.png)

or

![alt text](ZC1001.png "title text")

if you want to distinguish between alt and title text?

rmshkmr commented 8 years ago

@todvora i tried the same... it is not working in the new gitbook (updated). It is working fine in my old books.

todvora commented 7 years ago

Hi @rmshkmr, The handling of markdown files has been changed recently in 3.1.0 release and it should make no difference, if you write down the image as a raw HTML or markdown. This should also fix your issue.

I used your example as a test case and everything seems to be working now.

Please give it a try and let me know if everything works for you now.

Thanks, Tomas

rmshkmr commented 7 years ago

Thanks @todvora

todvora commented 7 years ago

Hi @rmshkmr, I hope it's confirmation that the issue is resolved for you. I am closing it now but feel free to reopen if the problem persists.

Ocxs commented 7 years ago

@todvora Hi, I meet same error.

my book.json is

{
    "gitbook": "3.x.x",
    "plugins": ["mathjax", 
                "multipart",
                "image-captions"],
    "links": {
        "sidebar": {
            "Contact us / Support": "https://www.gitbook.com/contact"
        }
    },
    "pluginsConfig": {
        "image-captions": {
          "caption": "image _PAGE_LEVEL_._PAGE_IMAGE_NUMBER_ - _CAPTION_"
      }
    }
}

and I use ![ZC1001](ZC1001.png), plugins can not create caption ZC1001.

My gitbook version is 3.2.2, CLI version is 2.3.0