[Trac-tickets] [The Trac Project] #1828: mimeviewer:tab_width in
config is not work for browser
The Trac Project
noreply at edgewall.com
Sun Jul 24 00:24:15 CDT 2005
#1828: mimeviewer:tab_width in config is not work for browser
---------------------+------------------------------------------------------
Id: 1828 | Status: new
Component: browser | Modified: Sun Jul 24 00:24:15 2005
Severity: normal | Milestone:
Priority: normal | Version: devel
Owner: jonas | Reporter: Shun-ichi Goto <gotoh at taiyo.co.jp>
---------------------+------------------------------------------------------
On browsing source file, tab-width 8 is always used although specifying
{{{[mimeviewer] tab_width}}}.
I made a patch, but it may not correct fix.
{{{
--- api.py (revision 2017)
+++ api.py (working copy)
@@ -216,6 +216,11 @@
candidates.append((qr, renderer))
candidates.sort(lambda x,y: cmp(y[0], x[0]))
+ tab_width = int(self.config.get('mimeviewer', 'tab_width'))
+
+ if mimetype.lower().startswith('text/'):
+ content = content.expandtabs(tab_width)
+
for qr, renderer in candidates:
try:
self.log.debug('Trying to render HTML preview using %s'
@@ -226,11 +231,10 @@
elif isinstance(result, (str, unicode)):
return result
elif annotations:
- return self._annotate(result, annotations)
+ return self._annotate(result, annotations, tab_width)
else:
buf = StringIO()
buf.write('<div class="code-block"><pre>')
- tab_width = int(self.config.get('mimeviewer',
'tab_width'))
for line in result:
buf.write(line.expandtabs(tab_width) + '\n')
buf.write('</pre></div>')
@@ -239,7 +243,7 @@
self.log.warning('HTML preview using %s failed (%s)'
% (renderer, e), exc_info=True)
- def _annotate(self, lines, annotations):
+ def _annotate(self, lines, annotations, tab_width):
buf = StringIO()
buf.write('<table class="code-block listing"><thead><tr>')
annotators = []
@@ -259,7 +263,6 @@
div, mod = divmod(len(m), 2)
return div * ' ' + mod * ' '
return (match.group('tag') or '') + ' '
- tab_width = int(self.config.get('mimeviewer', 'tab_width'))
for num, line in enum(_html_splitlines(lines)):
cells = []
}}}
I'm using r2017.
There's relating ticket:1655.
--
Ticket URL: <http://projects.edgewall.com/trac/ticket/1828>
The Trac Project <>
More information about the Trac-Tickets
mailing list