Skip to content
This repository
Browse code

Adding page break logic to the print css.

* I have added page-break-inside logic to div.input and
  div.output_area.
* Fixed a bug in CodeCell that was putting the output_area class
  on the wrong div.
  • Loading branch information...
commit 898a609ace1e50eee9f101d768e58647242826c5 1 parent d5b4ff0
Brian E. Granger ellisonbg authored
12 IPython/frontend/html/notebook/static/css/notebook.css
@@ -184,6 +184,10 @@ div.prompt {
184 184 font-family: monospace;
185 185 }
186 186
  187 +div.input {
  188 + page-break-inside: avoid;
  189 +}
  190 +
187 191 div.input_area {
188 192 color: black;
189 193 }
@@ -203,7 +207,8 @@ div.output_prompt {
203 207
204 208 /* This class is applied to all types of output (pyout, pyerr, stream, display_data) */
205 209 div.output_area {
206   - padding: 0px 0.4em
  210 + padding: 0px 0.4em;
  211 + page-break-inside: avoid;
207 212 }
208 213
209 214 /* This is the output area after the Out[] prompt of type pyout */
@@ -295,3 +300,8 @@ div.text_cell_render {
295 300 font-family: monospace;
296 301 }
297 302
  303 +@media print {
  304 + body { overflow: visible !important; }
  305 + .ui-widget-content { border: 0px; }
  306 +}
  307 +
30 IPython/frontend/html/notebook/static/js/codecell.js
@@ -206,12 +206,12 @@ var IPython = (function (IPython) {
206 206
207 207 CodeCell.prototype.append_pyout = function (json) {
208 208 n = json.prompt_number || ' ';
209   - var toinsert = $("<div/>").addClass("output_pyout hbox");
  209 + var toinsert = $("<div/>").addClass("output_pyout hbox output_area");
210 210 toinsert.append($('<div/>').
211 211 addClass('prompt output_prompt').
212 212 html('Out[' + n + ']:')
213 213 );
214   - this.append_mime_type(json, toinsert).addClass('output_area');
  214 + this.append_mime_type(json, toinsert);
215 215 toinsert.children().last().addClass("box_flex1 pyout_area");
216 216 this.element.find("div.output").append(toinsert);
217 217 // If we just output latex, typeset it.
@@ -252,19 +252,19 @@ var IPython = (function (IPython) {
252 252 CodeCell.prototype.append_mime_type = function (json, element) {
253 253 element = element || this.element.find("div.output");
254 254 if (json.html !== undefined) {
255   - this.append_html(json.html, element);
  255 + inserted = this.append_html(json.html, element);
256 256 } else if (json.latex !== undefined) {
257   - this.append_latex(json.latex, element);
  257 + inserted = this.append_latex(json.latex, element);
258 258 } else if (json.svg !== undefined) {
259   - this.append_svg(json.svg, element);
  259 + inserted = this.append_svg(json.svg, element);
260 260 } else if (json.png !== undefined) {
261   - this.append_png(json.png, element);
  261 + inserted = this.append_png(json.png, element);
262 262 } else if (json.jpeg !== undefined) {
263   - this.append_jpeg(json.jpeg, element);
  263 + inserted = this.append_jpeg(json.jpeg, element);
264 264 } else if (json.text !== undefined) {
265   - this.append_text(json.text, element);
  265 + inserted = this.append_text(json.text, element);
266 266 };
267   - return element;
  267 + return inserted;
268 268 };
269 269
270 270
@@ -273,7 +273,7 @@ var IPython = (function (IPython) {
273 273 var toinsert = $("<div/>").addClass("output_html rendered_html");
274 274 toinsert.append(html);
275 275 element.append(toinsert);
276   - return element;
  276 + return toinsert;
277 277 }
278 278
279 279
@@ -282,7 +282,7 @@ var IPython = (function (IPython) {
282 282 var toinsert = $("<div/>").addClass("output_stream");
283 283 toinsert.append($("<pre/>").html(data));
284 284 element.append(toinsert);
285   - return element;
  285 + return toinsert;
286 286 };
287 287
288 288
@@ -291,7 +291,7 @@ var IPython = (function (IPython) {
291 291 var toinsert = $("<div/>").addClass("output_svg");
292 292 toinsert.append(svg);
293 293 element.append(toinsert);
294   - return element;
  294 + return toinsert;
295 295 };
296 296
297 297
@@ -300,7 +300,7 @@ var IPython = (function (IPython) {
300 300 var toinsert = $("<div/>").addClass("output_png");
301 301 toinsert.append($("<img/>").attr('src','data:image/png;base64,'+png));
302 302 element.append(toinsert);
303   - return element;
  303 + return toinsert;
304 304 };
305 305
306 306
@@ -309,7 +309,7 @@ var IPython = (function (IPython) {
309 309 var toinsert = $("<div/>").addClass("output_jpeg");
310 310 toinsert.append($("<img/>").attr('src','data:image/jpeg;base64,'+jpeg));
311 311 element.append(toinsert);
312   - return element;
  312 + return toinsert;
313 313 };
314 314
315 315
@@ -320,7 +320,7 @@ var IPython = (function (IPython) {
320 320 var toinsert = $("<div/>").addClass("output_latex");
321 321 toinsert.append(latex);
322 322 element.append(toinsert);
323   - return element;
  323 + return toinsert;
324 324 }
325 325
326 326
2  IPython/frontend/html/notebook/static/js/printwidget.js
@@ -51,4 +51,4 @@ var IPython = (function (IPython) {
51 51
52 52 return IPython;
53 53
54   -}(IPython));
  54 +}(IPython));
2  IPython/frontend/html/notebook/templates/notebook.html
@@ -69,7 +69,7 @@ <h3 class="section_header">Notebook</h3>
69 69 </span>
70 70 <span class="section_row_buttons">
71 71 <span id="print_widget">
72   - <button id="print_notebook">Print/HTML</button>
  72 + <button id="print_notebook">Print</button>
73 73 </span>
74 74
75 75 <button id="download_notebook">Export</button>

0 comments on commit 898a609

Please sign in to comment.
Something went wrong with that request. Please try again.