Skip to content

image height + width attributes in markdown_github output #2554

Closed
peterjc opened this Issue · 6 comments

3 participants

@peterjc

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

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

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

test

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">

@peterjc peterjc referenced this issue in peterjc/mediawiki_to_git_md
Open

Image scaling during MediaWiki to Markdown conversion #10

@mb21

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

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

@jgm
Owner
@mb21

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

@jgm jgm added a commit that closed this issue
@jgm Markdown writer: use raw HTML for link/image attributes when
the `link_attributes` extension is unset and `raw_html` is set.

Closes #2554.
6d91fb2
@jgm jgm closed this in 6d91fb2
@peterjc

Lovely - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.