##// END OF EJS Templates
Options to exclude certain sections (source code or cell output) from exported result
Rick Lupton -
Show More
@@ -40,7 +40,7 b' class ConverterLaTeX(Converter):'
40 5: r'\subparagraph',
40 5: r'\subparagraph',
41 6: r'\subparagraph'}
41 6: r'\subparagraph'}
42 user_preamble = None
42 user_preamble = None
43 exclude_cells = None
43 exclude_cells = []
44
44
45 def in_env(self, environment, lines):
45 def in_env(self, environment, lines):
46 """Return list of environment lines for input lines
46 """Return list of environment lines for input lines
@@ -107,14 +107,19 b' class ConverterLaTeX(Converter):'
107
107
108 # Cell codes first carry input code, we use lstlisting for that
108 # Cell codes first carry input code, we use lstlisting for that
109 lines = [ur'\begin{codecell}']
109 lines = [ur'\begin{codecell}']
110
110
111 lines.extend(self.in_env('codeinput',
111 if 'source' not in self.exclude_cells:
112 self.in_env('lstlisting', cell.input)))
112 lines.extend(self.in_env('codeinput',
113 self.in_env('lstlisting', cell.input)))
114 else:
115 # Empty output is still needed for LaTeX formatting
116 lines.extend(self.in_env('codeinput', ''))
113
117
114 outlines = []
118 outlines = []
115 for output in cell.outputs:
119 if 'output' not in self.exclude_cells:
116 conv_fn = self.dispatch(output.output_type)
120 for output in cell.outputs:
117 outlines.extend(conv_fn(output))
121 conv_fn = self.dispatch(output.output_type)
122 outlines.extend(conv_fn(output))
118
123
119 # And then output of many possible types; use a frame for all of it.
124 # And then output of many possible types; use a frame for all of it.
120 if outlines:
125 if outlines:
@@ -75,7 +75,11 b" if __name__ == '__main__':"
75 known_formats)
75 known_formats)
76 parser.add_argument('-p', '--preamble',
76 parser.add_argument('-p', '--preamble',
77 help='Path to a user-specified preamble file')
77 help='Path to a user-specified preamble file')
78 parser.add_argument('-e', '--exclude', help='Comma-separated list of cells to exclude')
78 parser.add_argument('-e', '--exclude', default='',
79 help='Comma-separated list of cells to exclude')
80
79 args = parser.parse_args()
81 args = parser.parse_args()
82 exclude_cells = [s.strip() for s in args.exclude.split(',')]
83
80 main(infile=args.infile[0], format=args.format,
84 main(infile=args.infile[0], format=args.format,
81 preamble=args.preamble, exclude=args.exclude)
85 preamble=args.preamble, exclude=exclude_cells)
General Comments 0
You need to be logged in to leave comments. Login now