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 scaling during MediaWiki to Markdown conversion #10

Open
peterjc opened this issue Mar 7, 2015 · 5 comments
Open

Image scaling during MediaWiki to Markdown conversion #10

peterjc opened this issue Mar 7, 2015 · 5 comments

Comments

@peterjc
Copy link
Owner

peterjc commented Mar 7, 2015

Reported by @vincentdavis on issue #1

Some images are scaled, e.g. in http://biopython.org/wiki/Phylo or its MediaWiki equivalent https://github.com/peterjc/peterjc.github.io/blob/master/wiki/Phylo.mediawiki

[[File:phylo-draw-apaf1.png|256px|thumb|right|Rooted phylogram, via Phylo.draw]]

which becomes after conversion to GFM markdown with pandoc https://github.com/peterjc/peterjc.github.io/blob/master/wiki/Phylo.md

![Rooted phylogram, via Phylo.draw](phylo-draw-apaf1.png "fig:Rooted phylogram, via Phylo.draw")

On the actual wiki the image URL is:
http://biopython.org/w/images/thumb/0/04/Phylo-draw-apaf1.png/256px-Phylo-draw-apaf1.png

If you what to see the full size image
http://biopython.org/w/images/0/04/Phylo-draw-apaf1.png

@vincentdavis found a document that suggests code like this can be used for scaling images.

[[ http://url.to/image.png | height = 100px ]]
@peterjc
Copy link
Owner Author

peterjc commented Nov 23, 2015

As of #1 and #11, we now have the "original" unscaled images within the output.

This bug is now simply how to convert the MediaWiki image markup into (GitHub Flavoured) Markdown while preserving the image scaling information.

This is likely a pandoc configuration question...

@peterjc
Copy link
Owner Author

peterjc commented Nov 23, 2015

Wow, according to http://stackoverflow.com/questions/24383700/resize-image-in-the-wiki-of-github-using-markdown GFM no longer supports the height or width syntax mentioned above.

@peterjc
Copy link
Owner Author

peterjc commented Nov 23, 2015

Looks like we'll have to switch to minimal HTML snippets for images, see for example http://stackoverflow.com/questions/22485796/markdown-smaller-images-sizes-not-supported-by-github

<img src="url" alt="alt text" width="whatever" height="whatever">

This might work better with <div> wrapper images as then whole unit is HTML...

@peterjc
Copy link
Owner Author

peterjc commented Nov 23, 2015

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

This appears to understand the height/width attributes when parsing mediawiki input: jgm/pandoc@244cd56#diff-f003790849ba78911adb2e3836757776L577

It remains to be seen it would be rendered when we request GFM output... jgm/pandoc#2554

@peterjc
Copy link
Owner Author

peterjc commented Jan 15, 2024

This ought to work with the pandoc fix (see issue linked to above), just need to find/make a test case to confirm this!

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

1 participant