@@ -33,7 +33,7 @@ module.exports = toHTML;
33
33
const STABILITY_TEXT_REG_EXP = / ( .* : ) \s * ( \d ) ( [ \s \S ] * ) / ;
34
34
35
35
// customized heading without id attribute
36
- var renderer = new marked . Renderer ( ) ;
36
+ const renderer = new marked . Renderer ( ) ;
37
37
renderer . heading = function ( text , level ) {
38
38
return '<h' + level + '>' + text + '</h' + level + '>\n' ;
39
39
} ;
@@ -42,7 +42,7 @@ marked.setOptions({
42
42
} ) ;
43
43
44
44
// TODO(chrisdickinson): never stop vomitting / fix this.
45
- var gtocPath = path . resolve ( path . join (
45
+ const gtocPath = path . resolve ( path . join (
46
46
__dirname ,
47
47
'..' ,
48
48
'..' ,
@@ -57,8 +57,8 @@ var gtocData = null;
57
57
* opts: input, filename, template, nodeVersion.
58
58
*/
59
59
function toHTML ( opts , cb ) {
60
- var template = opts . template ;
61
- var nodeVersion = opts . nodeVersion || process . version ;
60
+ const template = opts . template ;
61
+ const nodeVersion = opts . nodeVersion || process . version ;
62
62
63
63
if ( gtocData ) {
64
64
return onGtocLoaded ( ) ;
@@ -80,7 +80,7 @@ function toHTML(opts, cb) {
80
80
}
81
81
82
82
function onGtocLoaded ( ) {
83
- var lexed = marked . lexer ( opts . input ) ;
83
+ const lexed = marked . lexer ( opts . input ) ;
84
84
fs . readFile ( template , 'utf8' , function ( er , template ) {
85
85
if ( er ) return cb ( er ) ;
86
86
render ( {
@@ -123,10 +123,10 @@ function render(opts, cb) {
123
123
var lexed = opts . lexed ;
124
124
var filename = opts . filename ;
125
125
var template = opts . template ;
126
- var nodeVersion = opts . nodeVersion || process . version ;
126
+ const nodeVersion = opts . nodeVersion || process . version ;
127
127
128
128
// get the section
129
- var section = getSection ( lexed ) ;
129
+ const section = getSection ( lexed ) ;
130
130
131
131
filename = path . basename ( filename , '.md' ) ;
132
132
@@ -138,7 +138,7 @@ function render(opts, cb) {
138
138
buildToc ( lexed , filename , function ( er , toc ) {
139
139
if ( er ) return cb ( er ) ;
140
140
141
- var id = toID ( path . basename ( filename ) ) ;
141
+ const id = toID ( path . basename ( filename ) ) ;
142
142
143
143
template = template . replace ( / _ _ I D _ _ / g, id ) ;
144
144
template = template . replace ( / _ _ F I L E N A M E _ _ / g, filename ) ;
@@ -220,9 +220,9 @@ function parseText(lexed) {
220
220
// lists that come right after a heading are what we're after.
221
221
function parseLists ( input ) {
222
222
var state = null ;
223
- var savedState = [ ] ;
223
+ const savedState = [ ] ;
224
224
var depth = 0 ;
225
- var output = [ ] ;
225
+ const output = [ ] ;
226
226
let headingIndex = - 1 ;
227
227
let heading = null ;
228
228
@@ -353,7 +353,7 @@ function parseYAML(text) {
353
353
}
354
354
355
355
// Syscalls which appear in the docs, but which only exist in BSD / OSX
356
- var BSD_ONLY_SYSCALLS = new Set ( [ 'lchmod' ] ) ;
356
+ const BSD_ONLY_SYSCALLS = new Set ( [ 'lchmod' ] ) ;
357
357
358
358
// Handle references to man pages, eg "open(2)" or "lchmod(2)"
359
359
// Returns modified text, with such refs replace with HTML links, for example
@@ -363,7 +363,7 @@ function linkManPages(text) {
363
363
/ ( [ a - z . ] + ) \( ( \d ) ( [ a - z ] ? ) \) / gm,
364
364
( match , name , number , optionalCharacter ) => {
365
365
// name consists of lowercase letters, number is a single digit
366
- var displayAs = `${ name } (${ number } ${ optionalCharacter } )` ;
366
+ const displayAs = `${ name } (${ number } ${ optionalCharacter } )` ;
367
367
if ( BSD_ONLY_SYSCALLS . has ( name ) ) {
368
368
return ` <a href="https://www.freebsd.org/cgi/man.cgi?query=${ name } ` +
369
369
`&sektion=${ number } ">${ displayAs } </a>` ;
@@ -375,7 +375,7 @@ function linkManPages(text) {
375
375
}
376
376
377
377
function linkJsTypeDocs ( text ) {
378
- var parts = text . split ( '`' ) ;
378
+ const parts = text . split ( '`' ) ;
379
379
var i ;
380
380
var typeMatches ;
381
381
@@ -453,7 +453,7 @@ function buildToc(lexed, filename, cb) {
453
453
cb ( null , toc ) ;
454
454
}
455
455
456
- var idCounters = { } ;
456
+ const idCounters = { } ;
457
457
function getId ( text ) {
458
458
text = text . toLowerCase ( ) ;
459
459
text = text . replace ( / [ ^ a - z 0 - 9 ] + / g, '_' ) ;
0 commit comments