lms.djangoapps.course_wiki.plugins.markdownedx package#

Submodules#

lms.djangoapps.course_wiki.plugins.markdownedx.mdx_mathjax module#

Add MathJax Markdown support

Source: mayoff/python-markdown-mathjax

class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_mathjax.MathJaxExtension(**kwargs)#

Bases: Extension

extendMarkdown(md)#

Add the various processors and patterns to the Markdown Instance.

This method must be overridden by every extension.

Parameters:

md – The Markdown instance.

class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_mathjax.MathJaxPattern#

Bases: Pattern

handleMatch(m)#

Return a ElementTree element from the given match.

Subclasses should override this method.

Parameters:

m – A match object containing a match of the pattern.

Returns: An ElementTree Element object.

lms.djangoapps.course_wiki.plugins.markdownedx.mdx_mathjax.makeExtension(**kwargs)#

lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video module#

Embeds web videos using URLs. For instance, if a URL to an youtube video is found in the text submitted to markdown and it isn’t enclosed in parenthesis like a normal link in markdown, then the URL will be swapped with a embedded youtube video.

All resulting HTML is XHTML Strict compatible.

>>> import markdown

Test Metacafe

>>> s = "http://www.metacafe.com/watch/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room/"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://www.metacafe.com/fplayer/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room.swf" height="423" type="application/x-shockwave-flash" width="498"><param name="movie" value="http://www.metacafe.com/fplayer/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room.swf" /><param name="allowFullScreen" value="true" /></object></p>'

Test Metacafe with arguments

>>> markdown.markdown(s, ['video(metacafe_width=500,metacafe_height=425)'])
u'<p><object data="http://www.metacafe.com/fplayer/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room.swf" height="425" type="application/x-shockwave-flash" width="500"><param name="movie" value="http://www.metacafe.com/fplayer/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room.swf" /><param name="allowFullScreen" value="true" /></object></p>'

Test Link To Metacafe

>>> s = "[Metacafe link](http://www.metacafe.com/watch/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room/)"
>>> markdown.markdown(s, ['video'])
u'<p><a href="http://www.metacafe.com/watch/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room/">Metacafe link</a></p>'

Test Markdown Escaping

>>> s = "\http://www.metacafe.com/watch/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room/"
>>> markdown.markdown(s, ['video'])
u'<p>http://www.metacafe.com/watch/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room/</p>'
>>> s = "`http://www.metacafe.com/watch/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room/`"
>>> markdown.markdown(s, ['video'])
u'<p><code>http://www.metacafe.com/watch/yt-tZMsrrQCnx8/pycon_2008_django_sprint_room/</code></p>'

Test Youtube

>>> s = "http://www.youtube.com/watch?v=u1mA-0w8XPo&hd=1&fs=1&feature=PlayList&p=34C6046F7FEACFD3&playnext=1&playnext_from=PL&index=1"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://www.youtube.com/v/u1mA-0w8XPo&amp;hd=1&amp;fs=1&amp;feature=PlayList&amp;p=34C6046F7FEACFD3&amp;playnext=1&amp;playnext_from=PL&amp;index=1" height="344" type="application/x-shockwave-flash" width="425"><param name="movie" value="http://www.youtube.com/v/u1mA-0w8XPo&amp;hd=1&amp;fs=1&amp;feature=PlayList&amp;p=34C6046F7FEACFD3&amp;playnext=1&amp;playnext_from=PL&amp;index=1" /><param name="allowFullScreen" value="true" /></object></p>'

Test Youtube with argument

>>> markdown.markdown(s, ['video(youtube_width=200,youtube_height=100)'])
u'<p><object data="http://www.youtube.com/v/u1mA-0w8XPo&amp;hd=1&amp;fs=1&amp;feature=PlayList&amp;p=34C6046F7FEACFD3&amp;playnext=1&amp;playnext_from=PL&amp;index=1" height="100" type="application/x-shockwave-flash" width="200"><param name="movie" value="http://www.youtube.com/v/u1mA-0w8XPo&amp;hd=1&amp;fs=1&amp;feature=PlayList&amp;p=34C6046F7FEACFD3&amp;playnext=1&amp;playnext_from=PL&amp;index=1" /><param name="allowFullScreen" value="true" /></object></p>'

Test Youtube Link

>>> s = "[Youtube link](http://www.youtube.com/watch?v=u1mA-0w8XPo&feature=PlayList&p=34C6046F7FEACFD3&playnext=1&playnext_from=PL&index=1)"
>>> markdown.markdown(s, ['video'])
u'<p><a href="http://www.youtube.com/watch?v=u1mA-0w8XPo&amp;feature=PlayList&amp;p=34C6046F7FEACFD3&amp;playnext=1&amp;playnext_from=PL&amp;index=1">Youtube link</a></p>'

Test Dailymotion

>>> s = "http://www.dailymotion.com/relevance/search/ut2004/video/x3kv65_ut2004-ownage_videogames"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://www.dailymotion.com/swf/x3kv65_ut2004-ownage_videogames" height="405" type="application/x-shockwave-flash" width="480"><param name="movie" value="http://www.dailymotion.com/swf/x3kv65_ut2004-ownage_videogames" /><param name="allowFullScreen" value="true" /></object></p>'

Test Dailymotion again (Dailymotion and their crazy URLs)

>>> s = "http://www.dailymotion.com/us/video/x8qak3_iron-man-vs-bruce-lee_fun"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://www.dailymotion.com/swf/x8qak3_iron-man-vs-bruce-lee_fun" height="405" type="application/x-shockwave-flash" width="480"><param name="movie" value="http://www.dailymotion.com/swf/x8qak3_iron-man-vs-bruce-lee_fun" /><param name="allowFullScreen" value="true" /></object></p>'

Test Yahoo! Video

>>> s = "http://video.yahoo.com/watch/1981791/4769603"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf?ver=2.2.40" height="322" type="application/x-shockwave-flash" width="512"><param name="movie" value="http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf?ver=2.2.40" /><param name="allowFullScreen" value="true" /><param name="flashVars" value="id=4769603&amp;vid=1981791" /></object></p>'

Test Veoh Video

>>> s = "http://www.veoh.com/search/videos/q/mario#watch%3De129555XxCZanYD"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://www.veoh.com/videodetails2.swf?permalinkId=e129555XxCZanYD" height="341" type="application/x-shockwave-flash" width="410"><param name="movie" value="http://www.veoh.com/videodetails2.swf?permalinkId=e129555XxCZanYD" /><param name="allowFullScreen" value="true" /></object></p>'

Test Veoh Video Again (More fun URLs)

>>> s = "http://www.veoh.com/group/BigCatRescuers#watch%3Dv16771056hFtSBYEr"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://www.veoh.com/videodetails2.swf?permalinkId=v16771056hFtSBYEr" height="341" type="application/x-shockwave-flash" width="410"><param name="movie" value="http://www.veoh.com/videodetails2.swf?permalinkId=v16771056hFtSBYEr" /><param name="allowFullScreen" value="true" /></object></p>'

Test Veoh Video Yet Again (Even more fun URLs)

>>> s = "http://www.veoh.com/browse/videos/category/anime/watch/v181645607JyXPWcQ"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://www.veoh.com/videodetails2.swf?permalinkId=v181645607JyXPWcQ" height="341" type="application/x-shockwave-flash" width="410"><param name="movie" value="http://www.veoh.com/videodetails2.swf?permalinkId=v181645607JyXPWcQ" /><param name="allowFullScreen" value="true" /></object></p>'

Test Vimeo Video

>>> s = "http://www.vimeo.com/1496152"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://vimeo.com/moogaloop.swf?clip_id=1496152&amp;amp;server=vimeo.com" height="321" type="application/x-shockwave-flash" width="400"><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1496152&amp;amp;server=vimeo.com" /><param name="allowFullScreen" value="true" /></object></p>'

Test Vimeo Video with some GET values

>>> s = "http://vimeo.com/1496152?test=test"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://vimeo.com/moogaloop.swf?clip_id=1496152&amp;amp;server=vimeo.com" height="321" type="application/x-shockwave-flash" width="400"><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1496152&amp;amp;server=vimeo.com" /><param name="allowFullScreen" value="true" /></object></p>'

Test Blip.tv

>>> s = "http://blip.tv/file/get/Pycon-PlenarySprintIntro563.flv"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://blip.tv/scripts/flash/showplayer.swf?file=http://blip.tv/file/get/Pycon-PlenarySprintIntro563.flv" height="300" type="application/x-shockwave-flash" width="480"><param name="movie" value="http://blip.tv/scripts/flash/showplayer.swf?file=http://blip.tv/file/get/Pycon-PlenarySprintIntro563.flv" /><param name="allowFullScreen" value="true" /></object></p>'

Test Gametrailers

>>> s = "http://www.gametrailers.com/video/console-comparison-borderlands/58079"
>>> markdown.markdown(s, ['video'])
u'<p><object data="http://www.gametrailers.com/remote_wrap.php?mid=58079" height="392" type="application/x-shockwave-flash" width="480"><param name="movie" value="http://www.gametrailers.com/remote_wrap.php?mid=58079" /><param name="allowFullScreen" value="true" /></object></p>'
class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.Bliptv(pattern: str, md: Markdown | None = None)#

Bases: Pattern

handleMatch(m)#

Return a ElementTree element from the given match.

Subclasses should override this method.

Parameters:

m – A match object containing a match of the pattern.

Returns: An ElementTree Element object.

class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.Dailymotion(pattern: str, md: Markdown | None = None)#

Bases: Pattern

handleMatch(m)#

Return a ElementTree element from the given match.

Subclasses should override this method.

Parameters:

m – A match object containing a match of the pattern.

Returns: An ElementTree Element object.

class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.Gametrailers(pattern: str, md: Markdown | None = None)#

Bases: Pattern

handleMatch(m)#

Return a ElementTree element from the given match.

Subclasses should override this method.

Parameters:

m – A match object containing a match of the pattern.

Returns: An ElementTree Element object.

class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.Metacafe(pattern: str, md: Markdown | None = None)#

Bases: Pattern

handleMatch(m)#

Return a ElementTree element from the given match.

Subclasses should override this method.

Parameters:

m – A match object containing a match of the pattern.

Returns: An ElementTree Element object.

class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.Veoh(pattern: str, md: Markdown | None = None)#

Bases: Pattern

handleMatch(m)#

Return a ElementTree element from the given match.

Subclasses should override this method.

Parameters:

m – A match object containing a match of the pattern.

Returns: An ElementTree Element object.

class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.VideoExtension(**kwargs)#

Bases: Extension

add_inline(md, name, klass, re)#

Adds the inline link

extendMarkdown(md)#

Add the various processors and patterns to the Markdown Instance.

This method must be overridden by every extension.

Parameters:

md – The Markdown instance.

class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.Vimeo(pattern: str, md: Markdown | None = None)#

Bases: Pattern

handleMatch(m)#

Return a ElementTree element from the given match.

Subclasses should override this method.

Parameters:

m – A match object containing a match of the pattern.

Returns: An ElementTree Element object.

class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.Yahoo(pattern: str, md: Markdown | None = None)#

Bases: Pattern

handleMatch(m)#

Return a ElementTree element from the given match.

Subclasses should override this method.

Parameters:

m – A match object containing a match of the pattern.

Returns: An ElementTree Element object.

class lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.Youtube(pattern: str, md: Markdown | None = None)#

Bases: Pattern

handleMatch(m)#

Return a ElementTree element from the given match.

Subclasses should override this method.

Parameters:

m – A match object containing a match of the pattern.

Returns: An ElementTree Element object.

lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.flash_object(url, width, height)#
lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.makeExtension(**kwargs)#

lms.djangoapps.course_wiki.plugins.markdownedx.wiki_plugin module#

class lms.djangoapps.course_wiki.plugins.markdownedx.wiki_plugin.ExtendMarkdownPlugin#

Bases: BasePlugin

This plugin simply loads all of the markdown extensions we use in edX.

markdown_extensions = [<lms.djangoapps.course_wiki.plugins.markdownedx.mdx_mathjax.MathJaxExtension object>, <lms.djangoapps.course_wiki.plugins.markdownedx.mdx_video.VideoExtension object>]#

Module contents#