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

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

Issue 2772173002: set tab length to 2 (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 extension_configs = { 158 extension_configs = {
159 'markdown.extensions.toc': { 159 'markdown.extensions.toc': {
160 'slugify': _gitiles_slugify 160 'slugify': _gitiles_slugify
161 }, 161 },
162 } 162 }
163 163
164 contents = self._Read(path[1:]) 164 contents = self._Read(path[1:])
165 165
166 md = markdown.Markdown(extensions=extensions, 166 md = markdown.Markdown(extensions=extensions,
167 extension_configs=extension_configs, 167 extension_configs=extension_configs,
168 tab_length=2,
168 output_format='html4') 169 output_format='html4')
169 170
170 has_a_single_h1 = (len([line for line in contents.splitlines() 171 has_a_single_h1 = (len([line for line in contents.splitlines()
171 if (line.startswith('#') and 172 if (line.startswith('#') and
172 not line.startswith('##'))]) == 1) 173 not line.startswith('##'))]) == 1)
173 174
174 md.treeprocessors['adjust_toc'] = _AdjustTOC(has_a_single_h1) 175 md.treeprocessors['adjust_toc'] = _AdjustTOC(has_a_single_h1)
175 176
176 md_fragment = md.convert(contents).encode('utf-8') 177 md_fragment = md.convert(contents).encode('utf-8')
177 178
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 contents.text = 'Contents' 307 contents.text = 'Contents'
307 contents.tail = '\n' 308 contents.tail = '\n'
308 toc_aux = ElementTree.SubElement(toc_node, 'div', {'class': 'toc-aux'}) 309 toc_aux = ElementTree.SubElement(toc_node, 'div', {'class': 'toc-aux'})
309 toc_aux.text = '\n' 310 toc_aux.text = '\n'
310 toc_aux.append(ul_with_the_desired_toc_entries) 311 toc_aux.append(ul_with_the_desired_toc_entries)
311 toc_aux.tail = '\n' 312 toc_aux.tail = '\n'
312 313
313 314
314 if __name__ == '__main__': 315 if __name__ == '__main__':
315 sys.exit(main(sys.argv[1:])) 316 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698