# HG changeset patch
# User Keshav Kini <kini@member.ams.org>
# Date 1292261117 28800
# Node ID f91e8c13f6559d043186a2786bc121bdacd756bd
# Parent 4047e578febc6e9895d6b5650dc81f0515a170c5
Add support for "....: "style continuation line prefixes, such as the sage interpreter prompt displays (may be incomplete)
diff r 4047e578febc r f91e8c13f655 sagedoctest
a

b


248  248  """ 
249  249  Run the preparser on the documentation string s. 
250  250  This *only* preparses the input lines, i.e., those 
251   that begin with "sage:".or with "..." 
 251  that begin with "sage:", "....:", or "...". 
252  252  """ 
253  253  sl = s.lower() 
254  254  
… 
… 

286  286  # and an empty line, to ignore the output given in the test 
287  287  line += '\n' + ' '*i + 'ignore ...\n' 
288  288  t.append(line) 
 289  
 290  elif begin == '....:': 
 291  t.append(preparse_line_with_prompt(L)) 
289  292  
290  293  elif begin.startswith('...'): 
291  294  comment = last_prompt_comment 
… 
… 

384  387  while j < len(F) and L.endswith('\\') and not L.endswith('\\\\'): 
385  388  j += 1 
386  389  i += 1 
387   L = L[:1] + F[j].lstrip().lstrip('...').rstrip() 
 390  L = L[:1] + F[j].lstrip().lstrip('....:').lstrip('...').rstrip() 
388  391  L += '###_sage"line %s:_sage_ %s_sage"'%(i, L.strip()) 
389  392  j += 1 
390  393  i += 1 
… 
… 

477  480  if n == 0: 
478  481  return '' 
479  482  s += test_code(os.path.abspath(file_name)) 
480   
481   # Allow for "sage:" instead of the traditional Python ">>>". 
482   s = s.replace("sage:",">>>").replace('_sage"','') 
 483  
 484  # Allow for "sage: " and "....: " instead of the traditional Python ">>> " and "... ". 
 485  s = s.replace("sage:",">>>").replace("....:","...").replace('_sage"','') 
483  486  
484  487  return s 
485  488  
… 
… 

607  610  cnt += 1 
608  611  if cnt > 1000: 
609  612  break 
610   s = s.replace(':_sage_',':\n').replace('>>>','sage:') 
 613  s = s.replace(':_sage_',':\n').replace('>>>','sage:').replace('... ','....: ') 
611  614  c = '###line [09]*\n' 
612  615  r = re.compile(c) 
613  616  s = r.sub('\n',s) 