Coder Social home page Coder Social logo

mdx_picture's Introduction

mdx_picture: HTML 5.1 for Markdown

Build Status

Abstract

The HTML <picture> element is a container used to specify multiple <source>s for a specific <img>. The browser will choose the most suitable source according to the current layout of the page and the screen it will be displayed on:

<picture>
	<source srcset="pear-tablet.jpeg" media="(min-width: 1280px)">
	<source srcset="pear-mobile.jpeg" media="(min-width: 720px)">
	<img src="pear-tablet.jpeg" alt="The pear is juicy.">
</picture>

The <picture> was introduced in the HTML 5.1 draft and implemented only in most current browsers Firefox > 38, Chrome > 43. The lack of support of the tag by IE and Safari makes it imposible to use the plain <picture> element. Fortunately there is a plenty of polyfills which enables <picture> element in browsers without its support.

Objective

Implement a markdown extension with a markup for <picture> tag. Attention! The mdx_picture doesn't implement any polyfills, so it supports only browsers with native <picture> tag support. You should add a polyfill implementation by yourself.

Use

The markdown block

[picture]
	[720px]: pear-mobile.jpeg
	[1280px]: pear-tablet.jpeg
	![This picture loads on non-supporting browsers.](image.jpg "The image title")
[/picture]

gets converted to

<picture>
	<source srcset="pear-tablet.jpeg" media="(max-width: 1280px)">
	<source srcset="pear-mobile.jpeg" media="(max-width: 720px)">
	<img alt="This picture loads on non-supporting browsers." src="image.jpg" title="The image title" />
</picture>

Install

  • From PyPi pip install mdx_picture
  • From Github pip install git+git://github.com/speechkey/mdx_picture

Develop

  1. Create new virtual environment e.g. mkvirtualenv mdx_picture
  2. Install dependencies by pip install -r requirements.pip

Test

Test pip packet by python setup.py test or run test manually by python -m mdx_picture.tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.