Debian Codegraph @

citeproc/formatter/rst.py

raw
1
2 def escape(text):
3 text = text.replace('*', r'\*')
4 text = text.replace('`', r'\`')
5 return text
6
7
8 def preformat(text):
9 return escape(str(text))
10
11
12 class RoleWrapper(str):
13 role = None
14
15 @classmethod
16 def _wrap(cls, text):
17 return ':{role}:`{text}`'.format(role=cls.role, text=text)
18
19 def __new__(cls, text):
20 return super(RoleWrapper, cls).__new__(cls, cls._wrap(text))
21
22
23 class Italic(RoleWrapper):
24 role = 'emphasis'
25
26
27 class Oblique(Italic):
28 pass
29
30
31 class Bold(RoleWrapper):
32 role = 'strong'
33
34
35 Light = str
36 Underline = str
37
38
39 class Superscript(RoleWrapper):
40 role = 'superscript'
41
42
43 class Subscript(RoleWrapper):
44 role = 'subscript'
45
46
47 SmallCaps = str