PyEmbed is available as an extension to Python-Markdown. Embedding content is then a simple matter of using the special [!embed]
link tag. For example:
[!embed](http://www.youtube.com/watch?v=9bZkp7q19f0)
More examples can be seen on the examples page.
PyEmbed-Markdown can be installed using pip.
pip install pyembed-markdown
PyEmbed-Markdown can be passed as a standard extension to Python-Markdown:
>>> import markdown
>>> from pyembed.markdown import PyEmbedMarkdown
>>> html = markdown.markdown(text, extensions=[PyEmbedMarkdown()])
If you're using Pelican, simply add these lines to your pelicanconf.py file:
MARKDOWN = {
'extension_configs': {
'pyembed.markdown': {}
}
}
The default syntax for embedding is to create a link with text !embed
, and the URL of the content to embed.
For example, this source:
[!embed](http://www.youtube.com/watch?v=9bZkp7q19f0)
will result in the following HTML output:
<iframe width="480" height="270" src="http://www.youtube.com/embed/9bZkp7q19f0?feature=oembed" frameborder="0" allowfullscreen></iframe>
You can control the maximum size of the embedded content with the max_height
and / or max_width
parameters. For example:
[!embed?max_width=300](http://www.youtube.com/watch?v=9bZkp7q19f0)
[!embed?max_width=300&max_height=200](http://www.youtube.com/watch?v=9bZkp7q19f0)