Skip to content

Commit 472a7ab

Browse files
committed
Initial commit
0 parents  commit 472a7ab

18 files changed

+573
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.{json,html,svg,css,mdastrc,eslintrc}]
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build/
2+
components/
3+
coverage/
4+
build.js
5+
mdast-util-to-string.js
6+
mdast-util-to-string.min.js

.eslintrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"browser": true
5+
},
6+
"rules": {
7+
"quotes": [2, "single"]
8+
}
9+
}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
*.log
3+
bower_components/
4+
build/
5+
components/
6+
coverage/
7+
node_modules/
8+
build.js

.jscs.json

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
{
2+
"excludeFiles": [
3+
"build/",
4+
"components/",
5+
"coverage/",
6+
"node_modules/",
7+
"build.js",
8+
"mdast-util-to-string.js",
9+
"mdast-util-to-string.min.js"
10+
],
11+
"plugins": [
12+
"jscs-jsdoc"
13+
],
14+
"jsDoc": {
15+
"checkAnnotations": "jsdoc3",
16+
"checkParamNames": true,
17+
"requireParamTypes": true,
18+
"checkRedundantParams": true,
19+
"checkReturnTypes": true,
20+
"checkRedundantReturns": true,
21+
"requireReturnTypes": true,
22+
"checkTypes": "strictNativeCase",
23+
"checkRedundantAccess": true,
24+
"enforceExistence": true,
25+
"requireHyphenBeforeDescription": true
26+
},
27+
"requireCurlyBraces": [
28+
"if",
29+
"else",
30+
"for",
31+
"while",
32+
"do",
33+
"try",
34+
"catch"
35+
],
36+
"requireSpaceAfterKeywords": [
37+
"if",
38+
"else",
39+
"for",
40+
"while",
41+
"do",
42+
"switch",
43+
"return",
44+
"try",
45+
"catch"
46+
],
47+
"requireSpaceBeforeBlockStatements": true,
48+
"requireParenthesesAroundIIFE": true,
49+
"requireSpacesInConditionalExpression": true,
50+
"requireSpacesInAnonymousFunctionExpression": {
51+
"beforeOpeningRoundBrace": true,
52+
"beforeOpeningCurlyBrace": true
53+
},
54+
"requireSpacesInNamedFunctionExpression": {
55+
"beforeOpeningRoundBrace": true,
56+
"beforeOpeningCurlyBrace": true
57+
},
58+
"requireSpacesInFunctionExpression": {
59+
"beforeOpeningCurlyBrace": true
60+
},
61+
"requireBlocksOnNewline": true,
62+
"disallowPaddingNewlinesInBlocks": true,
63+
"disallowEmptyBlocks": true,
64+
"disallowSpacesInsideObjectBrackets": true,
65+
"disallowSpacesInsideArrayBrackets": true,
66+
"disallowSpacesInsideParentheses": true,
67+
"requireSpacesInsideObjectBrackets": "all",
68+
"disallowDanglingUnderscores": true,
69+
"disallowSpaceAfterObjectKeys": true,
70+
"requireCommaBeforeLineBreak": true,
71+
"requireOperatorBeforeLineBreak": [
72+
"?",
73+
"+",
74+
"-",
75+
"/",
76+
"*",
77+
"=",
78+
"==",
79+
"===",
80+
"!=",
81+
"!==",
82+
">",
83+
">=",
84+
"<",
85+
"<="
86+
],
87+
"requireSpaceBeforeBinaryOperators": [
88+
"+",
89+
"-",
90+
"/",
91+
"*",
92+
"=",
93+
"==",
94+
"===",
95+
"!=",
96+
"!=="
97+
],
98+
"requireSpaceAfterBinaryOperators": [
99+
"+",
100+
"-",
101+
"/",
102+
"*",
103+
"=",
104+
"==",
105+
"===",
106+
"!=",
107+
"!=="
108+
],
109+
"disallowSpaceAfterPrefixUnaryOperators": [
110+
"++",
111+
"--",
112+
"+",
113+
"-",
114+
"~",
115+
"!"
116+
],
117+
"disallowSpaceBeforePostfixUnaryOperators": [
118+
"++",
119+
"--"
120+
],
121+
"disallowImplicitTypeConversion": [
122+
"numeric",
123+
"boolean",
124+
"binary",
125+
"string"
126+
],
127+
"requireCamelCaseOrUpperCaseIdentifiers": true,
128+
"disallowKeywords": [
129+
"with"
130+
],
131+
"disallowMultipleLineStrings": true,
132+
"disallowMultipleLineBreaks": true,
133+
"validateLineBreaks": "LF",
134+
"validateQuoteMarks": "'",
135+
"disallowMixedSpacesAndTabs": true,
136+
"disallowTrailingWhitespace": true,
137+
"disallowTrailingComma": true,
138+
"disallowKeywordsOnNewLine": [
139+
"else"
140+
],
141+
"requireLineFeedAtFileEnd": true,
142+
"maximumLineLength": 78,
143+
"requireCapitalizedConstructors": true,
144+
"safeContextKeyword": "self",
145+
"requireDotNotation": true,
146+
"disallowYodaConditions": true,
147+
"validateJSDoc": {
148+
"checkParamNames": true,
149+
"checkRedundantParams": true,
150+
"requireParamTypes": true
151+
}
152+
}

.mdastignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bower_components/
2+
components/

.mdastrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"plugins": [
3+
"lint",
4+
"github",
5+
"yaml-config"
6+
],
7+
"settings": {
8+
"bullet": "*"
9+
}
10+
}

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: node_js
2+
script: npm run-script test-travis
3+
node_js:
4+
- '0.10'
5+
- '0.11'
6+
- '0.12'
7+
- iojs
8+
sudo: false
9+
after_script: npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls
10+
deploy:
11+
provider: npm
12+
email: tituswormer@gmail.com
13+
api_key:
14+
secure: Gc/q5MGR+a9HOe8pHbf+C/8W2eyRerk0+tC6ggeYNcmZdeP2jlaU+Be4TPHKrfXSCzZSIYPLaUenIVeQQ1kxUd9QeLRs1uqbrRdTFiG5blhKpvYSEIVlvx/3ys8kaMm9ScsthlWSkPmlfDduftfxCbrSimZajxUl7kD+c8M86wzxPzvpzzyELzX34RsQvjSeGI3FMFlD743EP2nnwXbo2F5KVojj92V3HT449dBnI4GoKpUTlu2PBL7EInmVIT+CGTdyJVE/qd99/xfbdH/zjESu5Xa+1CuVk3pd9le6sYOAeZRy9gc0/sU/mpX+0nXTSsqjb0kua6gC1qC+gjLs1LwgFxhlFy7Htz+uq1mHlESXD9PyMs7D2l772t5h5N2eVzqpl7Btxcue7p71qKKE3FSMdEoL/eV98zD9j+h9eGtbvzaXS8r7x1hIIYUAwv3TNyIVRujCaiFYJMsL/gplyCNuKcU4pJPr4u/1Udk8/IooT7Nff9r+Xsh06Sa4cxY2wyYSEffox5JIPioRQkr6pFl45mw3XITUaxIofr2dpFH6xnogKJhlVOsp3q5d0srYvn+Rh2Y2Vc5yG94G2UfKx5u8enru9/dJGOvJjgLBElhywuJdnvgZmv6rljj4tu5a/k8dfRlGxUNBJYUkvXa2seCiHGbVje5hhIlO6o6B2pc=
15+
on:
16+
repo: wooorm/mdast-util-to-string

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

bower.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "mdast-util-to-string",
3+
"main": "mdast-util-to-string.js",
4+
"description": "Utility to get the plain text content of a node",
5+
"license": "MIT",
6+
"keywords": [
7+
"mdast",
8+
"markdown",
9+
"node",
10+
"to",
11+
"string",
12+
"util",
13+
"utility"
14+
],
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/wooorm/mdast-util-to-string.git"
18+
},
19+
"authors": [
20+
"Titus Wormer <tituswormer@gmail.com>"
21+
],
22+
"ignore": [
23+
".*",
24+
"*.log",
25+
"*.md",
26+
"build/",
27+
"components/",
28+
"coverage/",
29+
"node_modules/",
30+
"build.js",
31+
"index.js",
32+
"test.js",
33+
"component.json",
34+
"package.json"
35+
]
36+
}

component.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "mdast-util-to-string",
3+
"version": "0.0.0",
4+
"description": "Utility to get the plain text content of a node",
5+
"license": "MIT",
6+
"keywords": [
7+
"mdast",
8+
"markdown",
9+
"node",
10+
"to",
11+
"string",
12+
"util",
13+
"utility"
14+
],
15+
"repository": "wooorm/mdast-util-to-string",
16+
"scripts": [
17+
"index.js"
18+
]
19+
}

history.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
mdast:
3+
setext: true
4+
---
5+
6+
<!--lint disable no-multiple-toplevel-headings-->

index.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @author Titus Wormer
3+
* @copyright 2015 Titus Wormer. All rights reserved.
4+
* @module mdast-util-to-string
5+
* @fileoverview Utility to get the text value of a node.
6+
*/
7+
8+
'use strict';
9+
10+
/**
11+
* Get the value of `node`. Checks, `value`,
12+
* `alt`, and `title`, in that order.
13+
*
14+
* @param {Node} node - Node to get the internal value of.
15+
* @return {string} - Textual representation.
16+
*/
17+
function valueOf(node) {
18+
return node &&
19+
(node.value ? node.value :
20+
(node.alt ? node.alt : node.title)) || '';
21+
}
22+
23+
/**
24+
* Returns the text content of a node. If the node itself
25+
* does not expose plain-text fields, `toString` will
26+
* recursivly try its children.
27+
*
28+
* @param {Node} node - Node to transform to a string.
29+
* @return {string} - Textual representation.
30+
*/
31+
function toString(node) {
32+
return valueOf(node) ||
33+
(node.children && node.children.map(toString).join('')) ||
34+
'';
35+
}
36+
37+
/*
38+
* Expose.
39+
*/
40+
41+
module.exports = toString;

0 commit comments

Comments
 (0)