Skip to content

Commit 6b4330c

Browse files
committed
Refator style
1 parent 6b8a22b commit 6b4330c

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

index.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ var is = require('hast-util-is-element')
1111

1212
module.exports = toNLCST
1313

14-
/* Elements representing source. */
14+
// Elements representing source.
1515
var SOURCE = ['code']
1616
var IGNORE = ['script', 'style', 'svg', 'math', 'del']
1717
var EXPLICIT = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']
1818

19-
/* Constants. */
19+
// Constants.
2020
var FLOW_ACCEPTING = [
2121
'body',
2222
'article',
@@ -43,14 +43,14 @@ var FLOW_ACCEPTING = [
4343
'dialog'
4444
]
4545

46-
/* Transform `tree` to `nlcst`. */
46+
// Transform `tree` to `nlcst`.
4747
function toNLCST(tree, file, Parser) {
4848
var parser
4949
var location
5050
var results
5151
var doc
5252

53-
/* Warn for invalid parameters. */
53+
// Warn for invalid parameters.
5454
if (!tree || !tree.type) {
5555
throw new Error('hast-util-to-nlcst expected node')
5656
}
@@ -59,7 +59,7 @@ function toNLCST(tree, file, Parser) {
5959
throw new Error('hast-util-to-nlcst expected file')
6060
}
6161

62-
/* Construct parser. */
62+
// Construct parser.
6363
if (!Parser) {
6464
throw new Error('hast-util-to-nlcst expected parser')
6565
}
@@ -72,9 +72,8 @@ function toNLCST(tree, file, Parser) {
7272
doc = String(file)
7373
parser = 'parse' in Parser ? Parser : new Parser()
7474

75-
/* Transform HAST into NLCST tokens, and pass these
76-
* into `parser.parse` to insert sentences, paragraphs
77-
* where needed. */
75+
// Transform HAST into NLCST tokens, and pass these into `parser.parse` to
76+
// insert sentences, paragraphs where needed.
7877
results = []
7978

8079
find(tree)
@@ -94,15 +93,15 @@ function toNLCST(tree, file, Parser) {
9493
if (node.type === 'root') {
9594
findAll(children)
9695
} else if (is(node) && !ignored(node)) {
97-
/* Explicit paragraph. */
9896
if (is(node, EXPLICIT)) {
97+
// Explicit paragraph.
9998
add(node)
100-
/* Slightly simplified version of:
101-
* https://html.spec.whatwg.org/#paragraphs */
10299
} else if (is(node, FLOW_ACCEPTING)) {
100+
// Slightly simplified version of:
101+
// https://html.spec.whatwg.org/#paragraphs
103102
implicit(flattenAll(children))
104-
/* Dig deeper. */
105103
} else {
104+
// Dig deeper.
106105
findAll(children)
107106
}
108107
}
@@ -179,7 +178,7 @@ function toNLCST(tree, file, Parser) {
179178
}
180179
}
181180

182-
/* Convert `node` (HAST) to NLCST. */
181+
// Convert `node` (hast) to nlcst.
183182
function one(node) {
184183
var type = node.type
185184
var tagName = type === 'element' ? node.tagName : null
@@ -211,7 +210,7 @@ function toNLCST(tree, file, Parser) {
211210
return patch(replacement, location, location.toOffset(position.start(node)))
212211
}
213212

214-
/* Convert all `children` (HAST) to NLCST. */
213+
// Convert all `children` (HAST) to NLCST.
215214
function all(children) {
216215
var length = children && children.length
217216
var index = -1
@@ -229,13 +228,11 @@ function toNLCST(tree, file, Parser) {
229228
return result
230229
}
231230

232-
/* Patch a position on each node in `nodes`.
233-
* `offset` is the offset in `file` this run of content
234-
* starts at.
235-
*
236-
* Note that NLCST nodes are concrete, meaning that their
237-
* starting and ending positions can be inferred from their
238-
* content. */
231+
// Patch a position on each node in `nodes`. `offset` is the offset in
232+
// `file` this run of content starts at.
233+
//
234+
// Note that NLCST nodes are concrete, meaning that their starting and ending
235+
// positions can be inferred from their content.
239236
function patch(nodes, location, offset) {
240237
var length = nodes.length
241238
var index = -1

0 commit comments

Comments
 (0)