1- /**
2- * @author Titus Wormer
3- * @copyright 2015 Titus Wormer
4- * @license MIT
5- * @module mdast:to-nlcst
6- * @fileoverview Transform MDAST to NLCST.
7- */
8-
91'use strict' ;
102
113/* Dependencies. */
@@ -28,15 +20,7 @@ var IGNORE = {
2820/* Constants. */
2921var C_NEWLINE = '\n' ;
3022
31- /**
32- * Transform `ast` into `nlcst`.
33- *
34- * @param {Node } tree - MDAST node.
35- * @param {File } file - Virtual file.
36- * @param {Parser|Function } Parser - (Instance of) NLCST
37- * parser.
38- * @return {NLCSTNode } - NLCST.
39- */
23+ /* Transform `tree` into `nlcst`. */
4024function toNLCST ( tree , file , Parser ) {
4125 var parser ;
4226 var location ;
@@ -74,18 +58,7 @@ function toNLCST(tree, file, Parser) {
7458 return parser . parse ( one ( tree , null , null , file , location , parser ) ) ;
7559}
7660
77- /**
78- * Convert `node` into NLCST.
79- *
80- * @param {MDASTNode } node - Node.
81- * @param {number? } index - Position of `node` in `parent`.
82- * @param {MDASTNode? } parent - Parent node of `node`.
83- * @param {File } file - Virtual file.
84- * @param {Object } location - Bound location info.
85- * @param {Parser } parser - NLCST parser.
86- * @return {Array.<NLCSTNode>? } - A list of NLCST nodes, if
87- * `node` could be converted.
88- */
61+ /* Convert `node` into NLCST. */
8962function one ( node , index , parent , file , location , parser ) {
9063 var type = node . type ;
9164 var pos = node . position ;
@@ -126,16 +99,7 @@ function one(node, index, parent, file, location, parser) {
12699 return replacement || null ;
127100}
128101
129- /**
130- * Convert all nodes in `parent` (mdast) into NLCST.
131- *
132- * @param {MDASTNode } parent - Parent node.
133- * @param {File } file - Virtual file.
134- * @param {Object } location - Bound location info.
135- * @param {Parser } parser - NLCST parser.
136- * @return {Array.<NLCSTNode> } - Concatenation of calling
137- * `one` on each MDASTNode in `parent`.
138- */
102+ /* Convert all nodes in `parent` (mdast) into NLCST. */
139103function all ( parent , file , location , parser ) {
140104 var children = parent . children ;
141105 var length = children && children . length ;
@@ -180,20 +144,9 @@ function all(parent, file, location, parser) {
180144 return result ;
181145}
182146
183- /**
184- * Patch a position on each node in `nodes`.
147+ /* Patch a position on each node in `nodes`.
185148 * `offset` is the offset in `file` this run of content
186- * starts at.
187- *
188- * Note that NLCST nodes are concrete, meaning that their
189- * starting and ending positions can be inferred from their
190- * content.
191- *
192- * @param {Array.<NLCSTNode> } nodes - NLCST nodes.
193- * @param {Object } location - Bound location info.
194- * @param {number } offset - Starting offset for `nodes`.
195- * @return {Array.<NLCSTNode> } - `nodes`.
196- */
149+ * starts at. */
197150function patch ( nodes , location , offset ) {
198151 var length = nodes . length ;
199152 var index = - 1 ;
0 commit comments