mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Merge pull request #1156 from jacksonmj/italics
Add support for italic formatting
This commit is contained in:
commit
5501b7cf63
@ -299,6 +299,10 @@ def bold(s):
|
||||
"""Returns the string s, bolded."""
|
||||
return '\x02%s\x02' % s
|
||||
|
||||
def italic(s):
|
||||
"""Returns the string s, italicised."""
|
||||
return '\x1D%s\x1D' % s
|
||||
|
||||
def reverse(s):
|
||||
"""Returns the string s, reverse-videoed."""
|
||||
return '\x16%s\x16' % s
|
||||
@ -355,6 +359,10 @@ def stripBold(s):
|
||||
"""Returns the string s, with bold removed."""
|
||||
return s.replace('\x02', '')
|
||||
|
||||
def stripItalic(s):
|
||||
"""Returns the string s, with italics removed."""
|
||||
return s.replace('\x1d', '')
|
||||
|
||||
_stripColorRe = re.compile(r'\x03(?:\d{1,2},\d{1,2}|\d{1,2}|,\d{1,2}|)')
|
||||
def stripColor(s):
|
||||
"""Returns the string s, with color removed."""
|
||||
@ -375,6 +383,7 @@ def stripFormatting(s):
|
||||
s = stripBold(s)
|
||||
s = stripReverse(s)
|
||||
s = stripUnderline(s)
|
||||
s = stripItalic(s)
|
||||
return s.replace('\x0f', '').replace('\x0F', '')
|
||||
|
||||
_containsFormattingRe = re.compile(r'[\x02\x03\x16\x1f]')
|
||||
|
@ -92,6 +92,11 @@ class FunctionsTestCase(SupyTestCase):
|
||||
self.assertEqual(s[0], '\x02')
|
||||
self.assertEqual(s[-1], '\x02')
|
||||
|
||||
def testItalic(self):
|
||||
s = ircutils.italic('foo')
|
||||
self.assertEqual(s[0], '\x1d')
|
||||
self.assertEqual(s[-1], '\x1d')
|
||||
|
||||
def testUnderline(self):
|
||||
s = ircutils.underline('foo')
|
||||
self.assertEqual(s[0], '\x1f')
|
||||
@ -126,6 +131,9 @@ class FunctionsTestCase(SupyTestCase):
|
||||
def testStripBold(self):
|
||||
self.assertEqual(ircutils.stripBold(ircutils.bold('foo')), 'foo')
|
||||
|
||||
def testStripItalic(self):
|
||||
self.assertEqual(ircutils.stripItalic(ircutils.italic('foo')), 'foo')
|
||||
|
||||
def testStripColor(self):
|
||||
self.assertEqual(ircutils.stripColor('\x02bold\x0302,04foo\x03bar\x0f'),
|
||||
'\x02boldfoobar\x0f')
|
||||
@ -149,6 +157,7 @@ class FunctionsTestCase(SupyTestCase):
|
||||
|
||||
def testStripFormatting(self):
|
||||
self.assertEqual(ircutils.stripFormatting(ircutils.bold('foo')), 'foo')
|
||||
self.assertEqual(ircutils.stripFormatting(ircutils.italic('foo')), 'foo')
|
||||
self.assertEqual(ircutils.stripFormatting(ircutils.reverse('foo')),
|
||||
'foo')
|
||||
self.assertEqual(ircutils.stripFormatting(ircutils.underline('foo')),
|
||||
|
Loading…
Reference in New Issue
Block a user