# -*- coding: iso-8859-1 -*- u''' MoinMoin - YouTubeVideo macro Version 0.1 Displays an embedded video <> If an video_id is not given, no element will be shown Examples: * <> * <> Repository for the macro: https://git.cpi.imtek.uni-freiburg.de/holgi/YouTubeVideoMacro @copyright: 2018 by Holger Frey @license: Beerware license ''' from MoinMoin import wikiutil def macro_YouTubeVideo(macro, video_id=None, width=None, height=None): request = macro.request _ = request.getText if video_id is None: # no video id given return macro.formatter.rawHTML(u'') video_id = wikiutil.escape(str(video_id)) if width is None: width_attrib = '' else: escaped = wikiutil.escape(str(width)) width_attrib = 'width="%s"' % escaped if height is None: height_attrib = '' else: escaped = wikiutil.escape(str(height)) height_attrib = 'height="%s"' % escaped tmp = (u'' ) html = tmp % (video_id, width_attrib, height_attrib) return macro.formatter.rawHTML(html)