##// END OF EJS Templates
Added an option to disable syntax highlighting in code blocks. Simply add the -p or --plain_output tag to the command. This is a fix for issue #21
Ivan Djokic -
Show More
@@ -90,8 +90,9 b' class Converter(object):'
90 # they have specific requirements.
90 # they have specific requirements.
91 display_data_priority = ['pdf', 'svg', 'png', 'jpg', 'text']
91 display_data_priority = ['pdf', 'svg', 'png', 'jpg', 'text']
92
92
93 def __init__(self, infile):
93 def __init__(self, infile, highlight):
94 self.infile = infile
94 self.infile = infile
95 self.highlight = highlight
95 self.infile_dir, infile_root = os.path.split(infile)
96 self.infile_dir, infile_root = os.path.split(infile)
96 infile_root = os.path.splitext(infile_root)[0]
97 infile_root = os.path.splitext(infile_root)[0]
97 self.clean_name = clean_filename(infile_root)
98 self.clean_name = clean_filename(infile_root)
@@ -102,7 +102,7 b' class ConverterHTML(Converter):'
102 '<div class="prompt input_prompt">In&nbsp;[%s]:</div>' % n
102 '<div class="prompt input_prompt">In&nbsp;[%s]:</div>' % n
103 )
103 )
104 lines.append('<div class="input_area box-flex1">')
104 lines.append('<div class="input_area box-flex1">')
105 lines.append(highlight(cell.input))
105 lines.append(highlight(cell.input) if self.highlight else cell.input)
106 lines.append('</div>') # input_area
106 lines.append('</div>') # input_area
107 lines.append('</div>') # input
107 lines.append('</div>') # input
108
108
@@ -45,7 +45,7 b' known_formats = \', \'.join([key + " (default)" if key == default_format else key'
45 for key in converters])
45 for key in converters])
46
46
47
47
48 def main(infile, format='rst', preamble=None, exclude=None):
48 def main(infile, highlight, format='rst', preamble=None, exclude=None):
49 """Convert a notebook to html in one step"""
49 """Convert a notebook to html in one step"""
50 try:
50 try:
51 ConverterClass = converters[format]
51 ConverterClass = converters[format]
@@ -53,7 +53,7 b" def main(infile, format='rst', preamble=None, exclude=None):"
53 raise SystemExit("Unknown format '%s', " % format +
53 raise SystemExit("Unknown format '%s', " % format +
54 "known formats are: " + known_formats)
54 "known formats are: " + known_formats)
55
55
56 converter = ConverterClass(infile)
56 converter = ConverterClass(infile, highlight)
57 converter.render()
57 converter.render()
58
58
59 #-----------------------------------------------------------------------------
59 #-----------------------------------------------------------------------------
@@ -77,9 +77,10 b" if __name__ == '__main__':"
77 help='Path to a user-specified preamble file')
77 help='Path to a user-specified preamble file')
78 parser.add_argument('-e', '--exclude', default='',
78 parser.add_argument('-e', '--exclude', default='',
79 help='Comma-separated list of cells to exclude')
79 help='Comma-separated list of cells to exclude')
80
80 parser.add_argument('-p', '--plain_output', action='store_false',
81 help='Plain output which will contain no syntax highlighting.')
81 args = parser.parse_args()
82 args = parser.parse_args()
82 exclude_cells = [s.strip() for s in args.exclude.split(',')]
83 exclude_cells = [s.strip() for s in args.exclude.split(',')]
83
84
84 main(infile=args.infile[0], format=args.format,
85 main(infile=args.infile[0], highlight=args.plain_output,
85 preamble=args.preamble, exclude=exclude_cells)
86 format=args.format, preamble=args.preamble, exclude=exclude_cells)
General Comments 0
You need to be logged in to leave comments. Login now