Browse Source

liquid_tags: added speakerdeck tag

Brian Hulette 7 years ago
parent
commit
c42a77bac8
2 changed files with 41 additions and 0 deletions
  1. 6 0
      liquid_tags/Readme.md
  2. 35 0
      liquid_tags/speakerdeck.py

+ 6 - 0
liquid_tags/Readme.md

@@ -93,6 +93,12 @@ are not specified, then the dimensions will be 640 (wide) by 390 (tall).
 If you experience issues with code generation (e.g., missing closing tags),
 If you experience issues with code generation (e.g., missing closing tags),
 add `SUMMARY_MAX_LENGTH = None` to your settings file.
 add `SUMMARY_MAX_LENGTH = None` to your settings file.
 
 
+## Speakerdeck Tag
+To insert a Speakerdeck viewer into your content, enable the
+`liquid_tags.speakerdeck` plugin and add the following to your source document:
+
+    {% speakerdeck speakerdeck_id %}
+
 ## Video Tag
 ## Video Tag
 To insert HTML5-friendly video into your content, enable the `liquid_tags.video`
 To insert HTML5-friendly video into your content, enable the `liquid_tags.video`
 plugin and add the following to your source document:
 plugin and add the following to your source document:

+ 35 - 0
liquid_tags/speakerdeck.py

@@ -0,0 +1,35 @@
+"""
+Speakerdeck Tag
+---------------
+This implements a Liquid-style speakerdeck tag for Pelican.
+
+Syntax
+------
+{% speakerdeck id %}
+
+Example
+-------
+{% speakerdeck 82b209c0f181013106da6eb14261a8ef %}
+
+Output
+------
+<script async class="speakerdeck-embed" data-id="82b209c0f181013106da6eb14261a8ef"
+ data-ratio="1.33333333333333" src="//speakerdeck.com/assets/embed.js"></script>
+"""
+from .mdx_liquid_tags import LiquidTags
+
+SYNTAX = "{% speakerdeck id %}"
+
+@LiquidTags.register('speakerdeck')
+def speakerdeck(preprocessor, tag, markup):
+    speakerdeck_out = """
+<script async class="speakerdeck-embed" data-id="{id}"
+data-ratio="1.33333333333333" src="//speakerdeck.com/assets/embed.js"></script>
+        """.format(id=markup)
+
+    return speakerdeck_out
+
+
+# ---------------------------------------------------
+# This import allows speakerdeck tag to be a Pelican plugin
+from liquid_tags import register  # noqa