@@ -30,7 +30,12 @@ var gtocPath = path.resolve(path.join(
3030var  gtocLoading  =  null ; 
3131var  gtocData  =  null ; 
3232
33- function  toHTML ( input ,  filename ,  template ,  cb )  { 
33+ /** 
34+  * opts: input, filename, template, nodeVersion. 
35+  */ 
36+ function  toHTML ( opts ,  cb )  { 
37+   var  template  =  opts . template ; 
38+ 
3439  if  ( gtocData )  { 
3540    return  onGtocLoaded ( ) ; 
3641  } 
@@ -51,10 +56,15 @@ function toHTML(input, filename, template, cb) {
5156  } 
5257
5358  function  onGtocLoaded ( )  { 
54-     var  lexed  =  marked . lexer ( input ) ; 
59+     var  lexed  =  marked . lexer ( opts . input ) ; 
5560    fs . readFile ( template ,  'utf8' ,  function ( er ,  template )  { 
5661      if  ( er )  return  cb ( er ) ; 
57-       render ( lexed ,  filename ,  template ,  cb ) ; 
62+       render ( { 
63+         lexed : lexed , 
64+         filename : opts . filename , 
65+         template : template , 
66+         nodeVersion : opts . nodeVersion , 
67+       } ,  cb ) ; 
5868    } ) ; 
5969  } 
6070} 
@@ -81,7 +91,14 @@ function toID(filename) {
8191    . replace ( / - + / g,  '-' ) ; 
8292} 
8393
84- function  render ( lexed ,  filename ,  template ,  cb )  { 
94+ /** 
95+  * opts: lexed, filename, template, nodeVersion. 
96+  */ 
97+ function  render ( opts ,  cb )  { 
98+   var  lexed  =  opts . lexed ; 
99+   var  filename  =  opts . filename ; 
100+   var  template  =  opts . template ; 
101+ 
85102  // get the section 
86103  var  section  =  getSection ( lexed ) ; 
87104
@@ -100,7 +117,7 @@ function render(lexed, filename, template, cb) {
100117    template  =  template . replace ( / _ _ I D _ _ / g,  id ) ; 
101118    template  =  template . replace ( / _ _ F I L E N A M E _ _ / g,  filename ) ; 
102119    template  =  template . replace ( / _ _ S E C T I O N _ _ / g,  section ) ; 
103-     template  =  template . replace ( / _ _ V E R S I O N _ _ / g,  process . version ) ; 
120+     template  =  template . replace ( / _ _ V E R S I O N _ _ / g,  opts . nodeVersion ) ; 
104121    template  =  template . replace ( / _ _ T O C _ _ / g,  toc ) ; 
105122    template  =  template . replace ( 
106123      / _ _ G T O C _ _ / g, 
0 commit comments