Skip to content

Commit

Permalink
debug youtube + font
Browse files Browse the repository at this point in the history
  • Loading branch information
Camille Boissel committed Apr 12, 2012
1 parent bb3e2da commit 3f774a5
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
55 changes: 55 additions & 0 deletions bbcode/bbtags/text_formatting.py
Expand Up @@ -558,6 +558,59 @@ class Right(TagNode):
def parse(self):
return '<p style="text-align:right;">%s</p>' % self.parse_inner()


class Font(ArgumentTagNode):
"""
Add special font to the text.
Usage:
[code lang=bbdocs linenos=0][font=<font>]Text[/font]
Arguments:
Allowed values for [i]font[/i]: Arial, Arial Black, Comic Sans MS, Courier New, Georgia, Impact, Sans-serif, Serif, Times New Roman, Trebuchet MS, Verdana
"""
_allowed = ('Arial', 'Arial Black', 'Comic Sans MS', 'Courier New', 'Georgia', 'Impact', 'Sans-serif', 'Serif', 'Times New Roman', 'Trebuchet MS', 'Verdana')
verbose_name = 'Font'
open_pattern = re.compile(patterns.single_argument % 'font', re.IGNORECASE)
close_pattern = re.compile(patterns.closing % 'font', re.IGNORECASE)

def parse(self):
if not self.argument:
return self.parse_inner()
arg = self.argument
if not arg in self._allowed:
soft_raise("Font '%s' not allowed." % arg)
return self.parse_inner()
return '<span style="font-family:%s">%s</span>' % (arg, self.parse_inner())


class IntSize(ArgumentTagNode):
"""
Changes the size of text.
Usage:
[code lang=bbdocs linenos=0][size=<size>]Text[/size][/code]
Arguments:
Allowed values for [i]size[/i]: 1, 2, 3, 4, 5, 6, 7
"""
_allowed = ('1', '2', '3', '4', '5', '6', '7')
open_pattern = re.compile(patterns.single_argument % 'size', re.IGNORECASE)
close_pattern = re.compile(patterns.closing % 'size', re.IGNORECASE)

def parse(self):
if not self.argument:
return self.parse_inner()
arg = self.argument.lower()
if not arg in self._allowed:
soft_raise("Size '%s' not allowed." % arg)
return self.parse_inner()
return '<font size="%s">%s</font>' % (arg, self.parse_inner())

register(Em)
register(Strong)
register(P)
Expand All @@ -578,3 +631,5 @@ def parse(self):
register(Left)
register(Center)
register(Right)
register(Font)
# register(IntSize)
14 changes: 5 additions & 9 deletions bbcode/bbtags/web.py
Expand Up @@ -120,9 +120,10 @@ class Youtube(TagNode):
Usage:
[code lang=bbdocs linenos=0][youtube]http://www.youtube.com/watch?v=FjPf6B8EVJI[/youtube][/code]
[code lang=bbdocs linenos=0][youtube]FjPf6B8EVJI[/youtube][/code]
"""
_video_id_pattern = re.compile('v=(\w+)')
verbose_name = 'Youtube'
_video_id_pattern = re.compile('([a-zA-Z0-9]+)')
open_pattern = re.compile(patterns.no_argument % 'youtube', re.IGNORECASE)
close_pattern = re.compile(patterns.closing % 'youtube', re.IGNORECASE)

Expand All @@ -144,12 +145,7 @@ def parse(self):
return self.raw_content
videoid = videoid[0]
return (
'<object width="560" height="340"><param name="movie" value="http:/'
'/www.youtube.com/v/%s&amp;hl=en&amp;fs=1&amp;"></param><param name'
'="allowFullScreen" value="true"></param><param name="allowscriptac'
'cess" value="always"></param><embed src="http://www.youtube.com/v/'
'%s&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" a'
'llowscriptaccess="always" allowfullscreen="true" width="560" heigh'
'<iframe width="560" height="315" src="http://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>' % videoid
)


Expand All @@ -170,7 +166,7 @@ class Dailymotion(TagNode):
[code lang=bbdocs linenos=0][dailymotion]xtg9f[/dailymotion][/code]
"""
verbose_name = 'Dailymotion'
_video_id_pattern = re.compile('([a-z0-9]+)')
_video_id_pattern = re.compile('([a-zA-Z0-9]+)')
open_pattern = re.compile(patterns.no_argument % 'dailymotion', re.IGNORECASE)
close_pattern = re.compile(patterns.closing % 'dailymotion', re.IGNORECASE)

Expand Down

0 comments on commit 3f774a5

Please sign in to comment.