File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ # -*- coding: utf-8 -*-
3+
4+ """
5+ A script to re-enable colour in .html files produced from IPython notebooks.
6+
7+ Based on a script in a GitHub gist with this copyright notice:
8+
9+ #----------------------------------------------------------------------------
10+ # Copyright (c) 2013 - Damián Avila
11+ #
12+ # Distributed under the terms of the Modified BSD License.
13+ #
14+ # A little snippet to fix @media print issue printing slides from IPython
15+ #-----------------------------------------------------------------------------
16+ """
17+
18+ import io
19+ import sys
20+
21+ notebook = sys .argv [1 ]
22+ assert notebook .endswith ('.html' )
23+ # notebook = 'jevans.ipynb'
24+ path = notebook [:- 5 ] + '.html'
25+ flag = u'@media print{*{text-shadow:none !important;color:#000 !important'
26+
27+ with io .open (path , 'r' ) as in_file :
28+ data = in_file .readlines ()
29+ for i , line in enumerate (data ):
30+ if line [:64 ] == flag :
31+ data [i ] = data [i ].replace ('color:#000 !important;' , '' )
32+
33+ with io .open (path , 'w' ) as out_file :
34+ out_file .writelines (data )
35+
36+ print ("You can now print your slides" )
You can’t perform that action at this time.
0 commit comments