Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image height + width attributes in markdown_github output #2554

Closed
peterjc opened this issue Nov 23, 2015 · 9 comments
Closed

image height + width attributes in markdown_github output #2554

peterjc opened this issue Nov 23, 2015 · 9 comments

Comments

@peterjc
Copy link

peterjc commented Nov 23, 2015

According to recent commit 244cd56 pandoc 1.16 will add basic support for image sizes.

I would like to specify image sizes for GitHub Flavour Markdown (GFM) and GitHub Pages rendered with Jekyll, using the output from pandoc.

Apparently GitHub briefly supported their own syntax for image sizes in GFM, but now an HTML snippet is required - see http://stackoverflow.com/questions/24383700/resize-image-in-the-wiki-of-github-using-markdown or https://gist.github.com/uupaa/f77d2bcf4dc7a294d109

i.e. If the image has no size information, continue to produce a classic markdown image. However, if the height or width is specified, in order to get a useful image displayed via GitHub, substitute the HTML snippet.

@peterjc
Copy link
Author

peterjc commented Nov 23, 2015

A few examples using the GFM as implemented in the GitHub issue tracker (close to but not identical to GitHub Pages rendered with Jekyll).

No scaling, use a standard markdown image ![test](https://github.com/favicon.ico)

test

Defunct GFM, ![test](https://github.com/favicon.ico | width=48)

![test](https://github.com/favicon.ico | width=48)

Another Markdown variant's style which does not work with GFM, ![test](https://github.com/favicon.ico =24x48)

![test](https://github.com/favicon.ico =24x48)

Sadly this kramdown variant does not work with GFM, ![test](https://github.com/favicon.ico){:height="24px" width="48px"}

test{:height="24px" width="48px"}

No scaling, with HTML <img src="https://github.com/favicon.ico">

Setting width to 48, with HTML <img src="https://github.com/favicon.ico" width="48">

Setting height to 24, with HTML <img src="https://github.com/favicon.ico" height="24">

Setting height to 24, and width to 48, with HTML <img src="https://github.com/favicon.ico" height="24" width="48">

@mb21
Copy link
Collaborator

mb21 commented Nov 24, 2015

markdown_github is defined as a bunch of extensions that are enabled (see the README). The width and height (and other) image attributes are enabled in the link_attributes extension (not enabled for markdown_github, so they are dropped).

So to support the requested feature, we'd have to create a new extension called github_images or so and change the Markdown writer accordingly.

@peterjc
Copy link
Author

peterjc commented Nov 24, 2015

Thanks for your architectural insights - this sounds non-trivial then.

@jgm
Copy link
Owner

jgm commented Nov 24, 2015

+++ Mauro Bieg [Nov 24 15 09:28 ]:

markdown_github is defined as a bunch of extensions that are enabled
(see the README). The width and height (and other) image attributes are
enabled in the link_attributes extension (not enabled for
markdown_github, so they are dropped).

So to support the requested feature, we'd have to create a new
extension called github_images or so and change the Markdown writer
accordingly.

I'm not sure why---all flavors of Markdown accept raw HTML,
so the plan of using HTML for images with attributes makes
sense without a new extension (well, we'd use the existing
raw_html extension).

This would become the default treatment not just for
markdown_github but for all markdowns without
link_attributes.

@mb21
Copy link
Collaborator

mb21 commented Nov 24, 2015

Right, of course. I didn't think of the raw_html extension...

@jgm jgm closed this as completed in 6d91fb2 Nov 25, 2015
@peterjc
Copy link
Author

peterjc commented Nov 25, 2015

Lovely - thanks!

@zhangbg
Copy link

zhangbg commented Oct 13, 2017

Thanks, it work!

@vishi9780
Copy link

is there is any way to resize the gif image

@regalstreak
Copy link

regalstreak commented Jun 19, 2020

Resize gifs using the same way you resize images using the <img> tag

<img src="https://media.giphy.com/media/cFkiFMDg3iFoI/giphy.gif" width="300" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants