##// END OF EJS Templates
Cleaning up markdown output.
Brian Granger -
Show More
@@ -475,9 +475,12 b" def highlight(src, lang='python'):"
475 class ConverterMarkdown(Converter):
475 class ConverterMarkdown(Converter):
476 extension = 'md'
476 extension = 'md'
477
477
478 def __init__(self, infile, highlight_source=False):
478 def __init__(self, infile, highlight_source=True, show_prompts=False,
479 inline_prompt=False):
479 super(ConverterMarkdown, self).__init__(infile)
480 super(ConverterMarkdown, self).__init__(infile)
480 self.highlight_source = highlight_source
481 self.highlight_source = highlight_source
482 self.show_prompts = show_prompts
483 self.inline_prompt = inline_prompt
481
484
482 @DocInherit
485 @DocInherit
483 def render_heading(self, cell):
486 def render_heading(self, cell):
@@ -488,13 +491,18 b' class ConverterMarkdown(Converter):'
488 if not cell.input:
491 if not cell.input:
489 return []
492 return []
490 lines = []
493 lines = []
491 #lines.append('----')
494 if self.show_prompts and not self.inline_prompt:
492 lines.extend(['*In[%s]:*' % cell.prompt_number, ''])
495 lines.extend(['*In[%s]:*' % cell.prompt_number, ''])
493 src = highlight(cell.input) if self.highlight_source else \
496 if self.show_prompts and self.inline_prompt:
494 indent(cell.input)
497 prompt = 'In[%s]: ' % cell.prompt_number
498 input_lines = cell.input.split('\n')
499 src = prompt + input_lines[0] + '\n' + indent('\n'.join(input_lines[1:]), nspaces=len(prompt))
500 else:
501 src = cell.input
502 src = highlight(src) if self.highlight_source else indent(src)
495 lines.extend([src, ''])
503 lines.extend([src, ''])
496 if cell.outputs:
504 if cell.outputs and self.show_prompts and not self.inline_prompt:
497 lines.extend(['==>', ''])
505 lines.extend(['*Out[%s]:*' % cell.prompt_number, ''])
498 for output in cell.outputs:
506 for output in cell.outputs:
499 conv_fn = self.dispatch(output.output_type)
507 conv_fn = self.dispatch(output.output_type)
500 lines.extend(conv_fn(output))
508 lines.extend(conv_fn(output))
@@ -538,7 +546,7 b' class ConverterMarkdown(Converter):'
538
546
539 @DocInherit
547 @DocInherit
540 def _img_lines(self, img_file):
548 def _img_lines(self, img_file):
541 return ['', '![image](%s)' % img_file, '']
549 return ['', '![](%s)' % img_file, '']
542
550
543 @DocInherit
551 @DocInherit
544 def render_display_format_text(self, output):
552 def render_display_format_text(self, output):
General Comments 0
You need to be logged in to leave comments. Login now