diff --git a/liquid_tags/Readme.md b/liquid_tags/Readme.md index e1591f1..2fff718 100644 --- a/liquid_tags/Readme.md +++ b/liquid_tags/Readme.md @@ -14,8 +14,8 @@ First, in your pelicanconf.py file, add the plugins you want to use: PLUGIN_PATH = '/path/to/pelican-plugins' PLUGINS = ['liquid_tags.img', 'liquid_tags.video', - 'liquid_tags.youtube', 'liquid_tags.include_code', - 'liquid_tags.notebook'] + 'liquid_tags.youtube', 'liquid_tags.vimeo', + 'liquid_tags.include_code', 'liquid_tags.notebook'] There are several options available @@ -34,6 +34,15 @@ To insert youtube video into a post, enable the The width and height are in pixels, and can be optionally specified. If they are not, then the dimensions will be 640 (wide) by 390 (tall). +## Vimeo Tag +To insert a Vimeo video into a post, enable the +``liquid_tags.vimeo`` plugin, and add to your document: + + {% vimeo vimeo_id [width] [height] %} + +The width and height are in pixels, and can be optionally specified. If they +are not, then the dimensions will be 640 (wide) by 390 (tall). + ## Video Tag To insert flash/HTML5-friendly video into a post, enable the ``liquid_tags.video`` plugin, and add to your document: diff --git a/liquid_tags/vimeo.py b/liquid_tags/vimeo.py new file mode 100644 index 0000000..6dc929a --- /dev/null +++ b/liquid_tags/vimeo.py @@ -0,0 +1,54 @@ +""" +Vimeo Tag +--------- +This implements a Liquid-style vimeo tag for Pelican, +based on the youtube tag which is in turn based on +the jekyll / octopress youtube tag [1]_ + +Syntax +------ +{% vimeo id [width height] %} + +Example +------- +{% vimeo 10739054 640 480 %} + +Output +------ +
+ +[1] https://gist.github.com/jamieowen/2063748 +""" +import re +from .mdx_liquid_tags import LiquidTags + +SYNTAX = "{% vimeo id [width height] %}" + +VIMEO = re.compile(r'(\w+)(\s+(\d+)\s(\d+))?') + + +@LiquidTags.register('vimeo') +def vimeo(preprocessor, tag, markup): + width = 640 + height = 390 + vimeo_id = None + + match = VIMEO.search(markup) + if match: + groups = match.groups() + vimeo_id = groups[0] + width = groups[2] or width + height = groups[3] or height + + if vimeo_id: + vimeo_out = ''.format(width=width, height=height, vimeo_id=vimeo_id) + else: + raise ValueError("Error processing input, " + "expected syntax: {0}".format(SYNTAX)) + + return vimeo_out + + +#---------------------------------------------------------------------- +# This import allows vimeo tag to be a Pelican plugin +from liquid_tags import register