| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3681b9b commit f9f85a0
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,14 +61,22 @@ testData.forEach(function(item) { | |||
| 61 | 61 | ||
| 62 | 62 | fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) { | |
| 63 | 63 | assert.ifError(err); | |
| 64 | - html(input, 'foo', 'doc/template.html', | ||
| 64 | + html( | ||
| 65 | + { | ||
| 66 | + input: input, | ||
| 67 | + filename: 'foo', | ||
| 68 | + template: 'doc/template.html', | ||
| 69 | + nodeVersion: process.version, | ||
| 70 | + }, | ||
| 71 | + | ||
| 65 | 72 | common.mustCall(function(err, output) { | |
| 66 | 73 | assert.ifError(err); | |
| 67 | 74 | ||
| 68 | 75 | const actual = output.replace(/\s/g, ''); | |
| 69 | 76 | // Assert that the input stripped of all whitespace contains the | |
| 70 | 77 | // expected list | |
| 71 | 78 | assert.notEqual(actual.indexOf(expected), -1); | |
| 72 | - })); | ||
| 79 | + }) | ||
| 80 | + ); | ||
| 73 | 81 | })); | |
| 74 | 82 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,11 +48,19 @@ function next(er, input) { | |||
| 48 | 48 | break; | |
| 49 | 49 | ||
| 50 | 50 | case 'html': | |
| 51 | - require('./html.js')(input, inputFile, template, nodeVersion, | ||
| 51 | + require('./html.js')( | ||
| 52 | + { | ||
| 53 | + input: input, | ||
| 54 | + filename: inputFile, | ||
| 55 | + template: template, | ||
| 56 | + nodeVersion: nodeVersion, | ||
| 57 | + }, | ||
| 58 | + | ||
| 52 | 59 | function(er, html) { | |
| 53 | 60 | if (er) throw er; | |
| 54 | 61 | console.log(html); | |
| 55 | - }); | ||
| 62 | + } | ||
| 63 | + ); | ||
| 56 | 64 | break; | |
| 57 | 65 | ||
| 58 | 66 | default: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,12 +30,12 @@ var gtocPath = path.resolve(path.join( | |||
| 30 | 30 | var gtocLoading = null; | |
| 31 | 31 | var gtocData = null; | |
| 32 | 32 | ||
| 33 | - function toHTML(input, filename, template, nodeVersion, cb) { | ||
| 34 | - if (typeof nodeVersion === 'function') { | ||
| 35 | - cb = nodeVersion; | ||
| 36 | - nodeVersion = null; | ||
| 37 | - } | ||
| 38 | - nodeVersion = nodeVersion || process.version; | ||
| 33 | + /** | ||
| 34 | + * opts: input, filename, template, nodeVersion. | ||
| 35 | + */ | ||
| 36 | + function toHTML(opts, cb) { | ||
| 37 | + var template = opts.template; | ||
| 38 | + var nodeVersion = opts.nodeVersion || process.version; | ||
| 39 | 39 | ||
| 40 | 40 | if (gtocData) { | |
| 41 | 41 | return onGtocLoaded(); | |
@@ -57,10 +57,15 @@ function toHTML(input, filename, template, nodeVersion, cb) { | |||
| 57 | 57 | } | |
| 58 | 58 | ||
| 59 | 59 | function onGtocLoaded() { | |
| 60 | - var lexed = marked.lexer(input); | ||
| 60 | + var lexed = marked.lexer(opts.input); | ||
| 61 | 61 | fs.readFile(template, 'utf8', function(er, template) { | |
| 62 | 62 | if (er) return cb(er); | |
| 63 | - render(lexed, filename, template, nodeVersion, cb); | ||
| 63 | + render({ | ||
| 64 | + lexed: lexed, | ||
| 65 | + filename: opts.filename, | ||
| 66 | + template: template, | ||
| 67 | + nodeVersion: nodeVersion, | ||
| 68 | + }, cb); | ||
| 64 | 69 | }); | |
| 65 | 70 | } | |
| 66 | 71 | } | |
@@ -87,13 +92,14 @@ function toID(filename) { | |||
| 87 | 92 | .replace(/-+/g, '-'); | |
| 88 | 93 | } | |
| 89 | 94 | ||
| 90 | - function render(lexed, filename, template, nodeVersion, cb) { | ||
| 91 | - if (typeof nodeVersion === 'function') { | ||
| 92 | - cb = nodeVersion; | ||
| 93 | - nodeVersion = null; | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - nodeVersion = nodeVersion || process.version; | ||
| 95 | + /** | ||
| 96 | + * opts: lexed, filename, template, nodeVersion. | ||
| 97 | + */ | ||
| 98 | + function render(opts, cb) { | ||
| 99 | + var lexed = opts.lexed; | ||
| 100 | + var filename = opts.filename; | ||
| 101 | + var template = opts.template; | ||
| 102 | + var nodeVersion = opts.nodeVersion || process.version; | ||
| 97 | 103 | ||
| 98 | 104 | // get the section | |
| 99 | 105 | var section = getSection(lexed); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments