20
20
* at runtime from the About dialog for additional information.
21
21
*****************************************************************************/
22
22
23
- /*global require,process,GLOBAL*/
23
+ /*global require,process,__dirname, GLOBAL*/
24
24
/*jslint nomen: false */
25
25
26
26
@@ -47,6 +47,8 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
47
47
nomnoml = require ( 'nomnoml' ) ,
48
48
toc = require ( "markdown-toc" ) ,
49
49
Canvas = require ( 'canvas' ) ,
50
+ header = fs . readFileSync ( path . resolve ( __dirname , 'header.html' ) ) ,
51
+ footer = fs . readFileSync ( path . resolve ( __dirname , 'footer.html' ) ) ,
50
52
options = require ( "minimist" ) ( process . argv . slice ( 2 ) ) ;
51
53
52
54
// Convert from nomnoml source to a target PNG file.
@@ -115,9 +117,9 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
115
117
// Prepend table of contents
116
118
markdown =
117
119
[ TOC_HEAD , toc ( markdown ) . content , "" , markdown ] . join ( "\n" ) ;
118
- this . push ( "<html><body>\n" ) ;
120
+ this . push ( header ) ;
119
121
this . push ( marked ( markdown ) ) ;
120
- this . push ( "\n</body></html>\n" ) ;
122
+ this . push ( footer ) ;
121
123
done ( ) ;
122
124
} ;
123
125
return transform ;
@@ -186,12 +188,12 @@ GLOBAL.window = GLOBAL.window || GLOBAL; // nomnoml expects window to be define
186
188
var destination = file . replace ( options [ 'in' ] , options . out ) ,
187
189
destPath = path . dirname ( destination ) ,
188
190
streamOptions = { } ;
189
- if ( file . match ( / p n g $ / ) ) {
191
+ if ( file . match ( / p n g $ / ) ) {
190
192
streamOptions . encoding = null ;
191
193
} else {
192
194
streamOptions . encoding = 'utf8' ;
193
195
}
194
-
196
+
195
197
mkdirp ( destPath , function ( err ) {
196
198
fs . createReadStream ( file , streamOptions )
197
199
. pipe ( fs . createWriteStream ( destination , streamOptions ) ) ;
0 commit comments