##// END OF EJS Templates
Fix latex formatting of docstrings, patch by Stefan van der Walt...
fperez -
Show More
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 970 2005-12-29 18:22:53Z fperez $"""
4 $Id: Magic.py 973 2005-12-29 18:51:56Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -231,11 +231,11 b' license. To use profiling, please install"python2.3-profiler" from non-free.""")'
231 print OInspect.getdoc(func)
231 print OInspect.getdoc(func)
232
232
233
233
234 def format_latex(self,str):
234 def format_latex(self,strng):
235 """Format a string for latex inclusion."""
235 """Format a string for latex inclusion."""
236
236
237 # Characters that need to be escaped for latex:
237 # Characters that need to be escaped for latex:
238 escape_re = re.compile(r'(%|_|\$)',re.MULTILINE)
238 escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE)
239 # Magic command names as headers:
239 # Magic command names as headers:
240 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
240 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
241 re.MULTILINE)
241 re.MULTILINE)
@@ -245,20 +245,25 b' license. To use profiling, please install"python2.3-profiler" from non-free.""")'
245 # Paragraph continue
245 # Paragraph continue
246 par_re = re.compile(r'\\$',re.MULTILINE)
246 par_re = re.compile(r'\\$',re.MULTILINE)
247
247
248 str = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',str)
248 # The "\n" symbol
249 str = cmd_re.sub(r'\\texttt{\g<cmd>}',str)
249 newline_re = re.compile(r'\\n')
250 str = par_re.sub(r'\\\\',str)
251 str = escape_re.sub(r'\\\1',str)
252 return str
253
250
254 def format_screen(self,str):
251 # Now build the string for output:
252 strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
253 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
254 strng = par_re.sub(r'\\\\',strng)
255 strng = escape_re.sub(r'\\\1',strng)
256 strng = newline_re.sub(r'\\textbackslash{}n',strng)
257 return strng
258
259 def format_screen(self,strng):
255 """Format a string for screen printing.
260 """Format a string for screen printing.
256
261
257 This removes some latex-type format codes."""
262 This removes some latex-type format codes."""
258 # Paragraph continue
263 # Paragraph continue
259 par_re = re.compile(r'\\$',re.MULTILINE)
264 par_re = re.compile(r'\\$',re.MULTILINE)
260 str = par_re.sub('',str)
265 strng = par_re.sub('',strng)
261 return str
266 return strng
262
267
263 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
268 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
264 """Parse options passed to an argument string.
269 """Parse options passed to an argument string.
@@ -1,5 +1,9 b''
1 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2
2
3 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
4 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
5 which was producing problems in the resulting manual.
6
3 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
7 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
4 (minor mods) to support network shares under win32.
8 (minor mods) to support network shares under win32.
5
9
General Comments 0
You need to be logged in to leave comments. Login now