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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 self._DoMD(path + '/README.md') | 140 self._DoMD(path + '/README.md') |
141 else: | 141 else: |
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_ext_blocks', | 151 'gitiles_ext_blocks', |
151 ] | 152 ] |
152 extension_configs = { | 153 extension_configs = { |
153 'markdown.extensions.toc': { | 154 'markdown.extensions.toc': { |
154 'slugify': _gitiles_slugify | 155 'slugify': _gitiles_slugify |
155 }, | 156 }, |
156 } | 157 } |
157 | 158 |
158 contents = self._Read(path[1:]) | 159 contents = self._Read(path[1:]) |
159 | 160 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 contents.text = 'Contents' | 264 contents.text = 'Contents' |
264 contents.tail = '\n' | 265 contents.tail = '\n' |
265 toc_aux = ElementTree.SubElement(toc_node, 'div', {'class': 'toc-aux'}) | 266 toc_aux = ElementTree.SubElement(toc_node, 'div', {'class': 'toc-aux'}) |
266 toc_aux.text = '\n' | 267 toc_aux.text = '\n' |
267 toc_aux.append(ul_with_the_desired_toc_entries) | 268 toc_aux.append(ul_with_the_desired_toc_entries) |
268 toc_aux.tail = '\n' | 269 toc_aux.tail = '\n' |
269 | 270 |
270 | 271 |
271 if __name__ == '__main__': | 272 if __name__ == '__main__': |
272 sys.exit(main(sys.argv[1:])) | 273 sys.exit(main(sys.argv[1:])) |
OLD | NEW |