16
16
* Dependencies.
17
17
*/
18
18
19
- var range = require ( 'mdast -range' ) ;
19
+ var range = require ( 'remark -range' ) ;
20
20
var toString = require ( 'nlcst-to-string' ) ;
21
21
22
22
/*
@@ -280,12 +280,71 @@ function toNLCST(file, Parser) {
280
280
281
281
module . exports = toNLCST ;
282
282
283
- } , { "mdast-range" :2 , "nlcst-to-string" :3 } ] , 2 :[ function ( require , module , exports ) {
283
+ } , { "nlcst-to-string" :2 , "remark-range" :3 } ] , 2 :[ function ( require , module , exports ) {
284
+ /**
285
+ * @author Titus Wormer
286
+ * @copyright 2014-2015 Titus Wormer
287
+ * @license MIT
288
+ * @module nlcst:to-string
289
+ * @fileoverview Transform an NLCST node into a string.
290
+ */
291
+
292
+ 'use strict' ;
293
+
294
+ /* eslint-env commonjs */
295
+
296
+ /**
297
+ * Stringify an NLCST node.
298
+ *
299
+ * @param {NLCSTNode|Array.<NLCSTNode> } node - Node to to
300
+ * stringify.
301
+ * @param {string } separator - Value to separate each item
302
+ * with.
303
+ * @return {string } - Stringified `node`.
304
+ */
305
+ function nlcstToString ( node , separator ) {
306
+ var values ;
307
+ var length ;
308
+ var children ;
309
+
310
+ separator = separator || '' ;
311
+
312
+ if ( typeof node . value === 'string' ) {
313
+ return node . value ;
314
+ }
315
+
316
+ children = 'length' in node ? node : node . children ;
317
+ length = children . length ;
318
+
319
+ /*
320
+ * Shortcut: This is pretty common, and a small performance win.
321
+ */
322
+
323
+ if ( length === 1 && 'value' in children [ 0 ] ) {
324
+ return children [ 0 ] . value ;
325
+ }
326
+
327
+ values = [ ] ;
328
+
329
+ while ( length -- ) {
330
+ values [ length ] = nlcstToString ( children [ length ] , separator ) ;
331
+ }
332
+
333
+ return values . join ( separator ) ;
334
+ }
335
+
336
+ /*
337
+ * Expose.
338
+ */
339
+
340
+ module . exports = nlcstToString ;
341
+
342
+ } , { } ] , 3 :[ function ( require , module , exports ) {
284
343
/**
285
344
* @author Titus Wormer
286
345
* @copyright 2015 Titus Wormer
287
346
* @license MIT
288
- * @module mdast :range
347
+ * @module remark :range
289
348
* @fileoverview Patch index-based range on mdast nodes.
290
349
*/
291
350
@@ -303,7 +362,7 @@ var visit = require('unist-util-visit');
303
362
* Calculate offsets for `lines`.
304
363
*
305
364
* @param {Array.<string> } lines - Lines to compile.
306
- * @return {Array.<number> }
365
+ * @return {Array.<number> } - List of offsets per line.
307
366
*/
308
367
function toOffsets ( lines ) {
309
368
var total = 0 ;
@@ -322,6 +381,7 @@ function toOffsets(lines) {
322
381
* Add an offset based on `offsets` to `position`.
323
382
*
324
383
* @param {Object } position - Position.
384
+ * @param {Function } fn - Calculator.
325
385
*/
326
386
function addRange ( position , fn ) {
327
387
position . offset = fn ( position ) ;
@@ -411,7 +471,7 @@ function transformer(ast, file) {
411
471
*/
412
472
413
473
if ( ! file || typeof file . contents !== 'string' ) {
414
- throw new Error ( 'Missing `file` for mdast -range' ) ;
474
+ throw new Error ( 'Missing `file` for remark -range' ) ;
415
475
}
416
476
417
477
/*
@@ -460,66 +520,7 @@ function attacher() {
460
520
461
521
module . exports = attacher ;
462
522
463
- } , { "unist-util-visit" :4 } ] , 3 :[ function ( require , module , exports ) {
464
- /**
465
- * @author Titus Wormer
466
- * @copyright 2014-2015 Titus Wormer
467
- * @license MIT
468
- * @module nlcst:to-string
469
- * @fileoverview Transform an NLCST node into a string.
470
- */
471
-
472
- 'use strict' ;
473
-
474
- /* eslint-env commonjs */
475
-
476
- /**
477
- * Stringify an NLCST node.
478
- *
479
- * @param {NLCSTNode|Array.<NLCSTNode> } node - Node to to
480
- * stringify.
481
- * @param {string } separator - Value to separate each item
482
- * with.
483
- * @return {string } - Stringified `node`.
484
- */
485
- function nlcstToString ( node , separator ) {
486
- var values ;
487
- var length ;
488
- var children ;
489
-
490
- separator = separator || '' ;
491
-
492
- if ( typeof node . value === 'string' ) {
493
- return node . value ;
494
- }
495
-
496
- children = 'length' in node ? node : node . children ;
497
- length = children . length ;
498
-
499
- /*
500
- * Shortcut: This is pretty common, and a small performance win.
501
- */
502
-
503
- if ( length === 1 && 'value' in children [ 0 ] ) {
504
- return children [ 0 ] . value ;
505
- }
506
-
507
- values = [ ] ;
508
-
509
- while ( length -- ) {
510
- values [ length ] = nlcstToString ( children [ length ] , separator ) ;
511
- }
512
-
513
- return values . join ( separator ) ;
514
- }
515
-
516
- /*
517
- * Expose.
518
- */
519
-
520
- module . exports = nlcstToString ;
521
-
522
- } , { } ] , 4 :[ function ( require , module , exports ) {
523
+ } , { "unist-util-visit" :4 } ] , 4 :[ function ( require , module , exports ) {
523
524
/**
524
525
* @author Titus Wormer
525
526
* @copyright 2015 Titus Wormer. All rights reserved.
0 commit comments