| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Simple Markdown browser for a Git checkout.""" | 5 """Simple Markdown browser for a Git checkout.""" |
| 6 from __future__ import print_function | 6 from __future__ import print_function |
| 7 | 7 |
| 8 import SimpleHTTPServer | 8 import SimpleHTTPServer |
| 9 import SocketServer | 9 import SocketServer |
| 10 import argparse | 10 import argparse |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 self._WriteTemplate('doc.css') | 94 self._WriteTemplate('doc.css') |
| 95 elif not os.path.exists(full_path): | 95 elif not os.path.exists(full_path): |
| 96 self._DoNotFound() | 96 self._DoNotFound() |
| 97 elif path.lower().endswith('.md'): | 97 elif path.lower().endswith('.md'): |
| 98 self._DoMD(path) | 98 self._DoMD(path) |
| 99 else: | 99 else: |
| 100 self._DoUnknown() | 100 self._DoUnknown() |
| 101 | 101 |
| 102 def _DoMD(self, path): | 102 def _DoMD(self, path): |
| 103 extensions = [ | 103 extensions = [ |
| 104 'markdown.extensions.def_list', |
| 104 'markdown.extensions.fenced_code', | 105 'markdown.extensions.fenced_code', |
| 105 'markdown.extensions.tables', | 106 'markdown.extensions.tables', |
| 106 'markdown.extensions.toc', | 107 'markdown.extensions.toc', |
| 107 'gitiles_ext_blocks', | 108 'gitiles_ext_blocks', |
| 108 ] | 109 ] |
| 109 extension_configs = { | 110 extension_configs = { |
| 110 'markdown.extensions.toc': { | 111 'markdown.extensions.toc': { |
| 111 'slugify': _gitiles_slugify | 112 'slugify': _gitiles_slugify |
| 112 }, | 113 }, |
| 113 } | 114 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 137 with codecs.open(path, encoding='utf-8') as fp: | 138 with codecs.open(path, encoding='utf-8') as fp: |
| 138 return fp.read() | 139 return fp.read() |
| 139 | 140 |
| 140 def _WriteTemplate(self, template): | 141 def _WriteTemplate(self, template): |
| 141 contents = self._Read(os.path.join('tools', 'md_browser', template)) | 142 contents = self._Read(os.path.join('tools', 'md_browser', template)) |
| 142 self.wfile.write(contents.encode('utf-8')) | 143 self.wfile.write(contents.encode('utf-8')) |
| 143 | 144 |
| 144 | 145 |
| 145 if __name__ == '__main__': | 146 if __name__ == '__main__': |
| 146 sys.exit(main(sys.argv[1:])) | 147 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |