showdown icon indicating copy to clipboard operation
showdown copied to clipboard

feat(image): optionally add image captions from alt tags

Open tlhunter opened this issue 7 years ago • 6 comments

This PR introduces a new option named extractImageCaptions to enable image captions.

Input

![An elephant at sunset](/elephant.jpg)

Output

(newlines added for PR readability, not included in code)

<p>
  <figure>
    <img src="/elephant.jpg" alt="An elephant at sunset" />
    <figcaption>An elephant at sunset</figcaption>
  </figure>
</p>

The inspiration for the output markup was taken from here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaption

Help Request: While the paragraph tags don't really hurt, they would ideally be removed. Any advice?

tlhunter avatar Nov 13 '18 06:11 tlhunter

FYI I'm using this PR on my personal site. Here's an example of a page rendered using this code: https://thomashunter.name/posts/2016-02-03-microsoft-sculpt-ergonomic-keyboard-review

And here's a screenshot (grey text below image): 20181118182233

tlhunter avatar Nov 19 '18 02:11 tlhunter

I will pay $10 via PayPal to get this merged and released via npm.

/cc @tivie

tlhunter avatar Dec 13 '18 20:12 tlhunter

thank you for your contribution.

I've been swamped in work lately, but will use the xmas vacations to look into this.

One important thing though, version 2.0 will have templates, which will enable users to easily and completely change the HTML output.

tivie avatar Dec 19 '18 12:12 tivie

PR has been updated to include the dist files.

tlhunter avatar Aug 02 '19 19:08 tlhunter

@tivie I'm interested in this feature. Is there an alternative way to get something equivalent now with 2.0? If not, can you get this merged?

marcelogp avatar Aug 12 '22 22:08 marcelogp

@marcelogp - this feature has already been added & is ready to use.

Tho - I don't know why this pull request was never merged from @tlhunter to implement it with his work done already! :disappointed:

Hoping @tivie is willing to close this PR to avoiding causing any future confusion.

ps - @tivie let's clean up some of these issues etc - feel free to get in contact with me etc.

MarketingPip avatar Aug 27 '22 08:08 MarketingPip