OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Simple Markdown browser for a Git checkout.""" | 6 """Simple Markdown browser for a Git checkout.""" |
7 from __future__ import print_function | 7 from __future__ import print_function |
8 | 8 |
9 import SimpleHTTPServer | 9 import SimpleHTTPServer |
10 import SocketServer | 10 import SocketServer |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 self._DoUnknown() | 142 self._DoUnknown() |
143 | 143 |
144 def _DoMD(self, path): | 144 def _DoMD(self, path): |
145 extensions = [ | 145 extensions = [ |
146 'markdown.extensions.def_list', | 146 'markdown.extensions.def_list', |
147 'markdown.extensions.fenced_code', | 147 'markdown.extensions.fenced_code', |
148 'markdown.extensions.tables', | 148 'markdown.extensions.tables', |
149 'markdown.extensions.toc', | 149 'markdown.extensions.toc', |
150 'gitiles_autolink', | 150 'gitiles_autolink', |
151 'gitiles_ext_blocks', | 151 'gitiles_ext_blocks', |
| 152 'gitiles_smart_quotes', |
152 ] | 153 ] |
153 extension_configs = { | 154 extension_configs = { |
154 'markdown.extensions.toc': { | 155 'markdown.extensions.toc': { |
155 'slugify': _gitiles_slugify | 156 'slugify': _gitiles_slugify |
156 }, | 157 }, |
157 } | 158 } |
158 | 159 |
159 contents = self._Read(path[1:]) | 160 contents = self._Read(path[1:]) |
160 | 161 |
161 md = markdown.Markdown(extensions=extensions, | 162 md = markdown.Markdown(extensions=extensions, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 contents.text = 'Contents' | 265 contents.text = 'Contents' |
265 contents.tail = '\n' | 266 contents.tail = '\n' |
266 toc_aux = ElementTree.SubElement(toc_node, 'div', {'class': 'toc-aux'}) | 267 toc_aux = ElementTree.SubElement(toc_node, 'div', {'class': 'toc-aux'}) |
267 toc_aux.text = '\n' | 268 toc_aux.text = '\n' |
268 toc_aux.append(ul_with_the_desired_toc_entries) | 269 toc_aux.append(ul_with_the_desired_toc_entries) |
269 toc_aux.tail = '\n' | 270 toc_aux.tail = '\n' |
270 | 271 |
271 | 272 |
272 if __name__ == '__main__': | 273 if __name__ == '__main__': |
273 sys.exit(main(sys.argv[1:])) | 274 sys.exit(main(sys.argv[1:])) |
OLD | NEW |