Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Side by Side Diff: tools/md_browser/md_browser.py

Issue 2740863004: support gitiles smart quoting (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/md_browser/gitiles_smart_quotes.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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:]))
OLDNEW
« no previous file with comments | « tools/md_browser/gitiles_smart_quotes.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698