38 |
38 |
39 class URLBinder: |
39 class URLBinder: |
40 def __init__(self, url, klass): |
40 def __init__(self, url, klass): |
41 self.base_url = url |
41 self.base_url = url |
42 self.translator_class = HTMLTranslator |
42 self.translator_class = HTMLTranslator |
43 |
43 |
44 def __call__(self, document): |
44 def __call__(self, document): |
45 translator = self.translator_class(document) |
45 translator = self.translator_class(document) |
46 translator.base_url = self.base_url |
46 translator.base_url = self.base_url |
47 return translator |
47 return translator |
48 |
48 |
49 class HTMLTranslator(CSS1HTMLTranslator): |
49 class HTMLTranslator(CSS1HTMLTranslator): |
50 """ReST tree to html translator""" |
50 """ReST tree to html translator""" |
51 |
51 |
52 def astext(self): |
52 def astext(self): |
53 """return the extracted html""" |
53 """return the extracted html""" |
54 return ''.join(self.body) |
54 return ''.join(self.body) |
55 |
55 |
56 def visit_title(self, node): |
56 def visit_title(self, node): |
57 """Only 6 section levels are supported by HTML.""" |
57 """Only 6 section levels are supported by HTML.""" |
58 if isinstance(node.parent, nodes.topic): |
58 if isinstance(node.parent, nodes.topic): |
59 self.body.append( |
59 self.body.append( |
60 self.starttag(node, 'p', '', CLASS='topic-title')) |
60 self.starttag(node, 'p', '', CLASS='topic-title')) |
122 def visit_problematic(self, node): |
122 def visit_problematic(self, node): |
123 pass |
123 pass |
124 |
124 |
125 def depart_problematic(self, node): |
125 def depart_problematic(self, node): |
126 pass |
126 pass |
127 |
127 |
128 def visit_system_message(self, node): |
128 def visit_system_message(self, node): |
129 backref_text = '' |
129 backref_text = '' |
130 if len(node['backrefs']): |
130 if len(node['backrefs']): |
131 backrefs = node['backrefs'] |
131 backrefs = node['backrefs'] |
132 if len(backrefs) == 1: |
132 if len(backrefs) == 1: |