Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 2, 2015
0 parents commit 472a7ab
Show file tree
Hide file tree
Showing 18 changed files with 573 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{json,html,svg,css,mdastrc,eslintrc}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build/
components/
coverage/
build.js
mdast-util-to-string.js
mdast-util-to-string.min.js
9 changes: 9 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"env": {
"node": true,
"browser": true
},
"rules": {
"quotes": [2, "single"]
}
}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
*.log
bower_components/
build/
components/
coverage/
node_modules/
build.js
152 changes: 152 additions & 0 deletions .jscs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{
"excludeFiles": [
"build/",
"components/",
"coverage/",
"node_modules/",
"build.js",
"mdast-util-to-string.js",
"mdast-util-to-string.min.js"
],
"plugins": [
"jscs-jsdoc"
],
"jsDoc": {
"checkAnnotations": "jsdoc3",
"checkParamNames": true,
"requireParamTypes": true,
"checkRedundantParams": true,
"checkReturnTypes": true,
"checkRedundantReturns": true,
"requireReturnTypes": true,
"checkTypes": "strictNativeCase",
"checkRedundantAccess": true,
"enforceExistence": true,
"requireHyphenBeforeDescription": true
},
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": true,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"requireBlocksOnNewline": true,
"disallowPaddingNewlinesInBlocks": true,
"disallowEmptyBlocks": true,
"disallowSpacesInsideObjectBrackets": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"requireSpacesInsideObjectBrackets": "all",
"disallowDanglingUnderscores": true,
"disallowSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
"requireOperatorBeforeLineBreak": [
"?",
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],
"requireSpaceBeforeBinaryOperators": [
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!=="
],
"requireSpaceAfterBinaryOperators": [
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!=="
],
"disallowSpaceAfterPrefixUnaryOperators": [
"++",
"--",
"+",
"-",
"~",
"!"
],
"disallowSpaceBeforePostfixUnaryOperators": [
"++",
"--"
],
"disallowImplicitTypeConversion": [
"numeric",
"boolean",
"binary",
"string"
],
"requireCamelCaseOrUpperCaseIdentifiers": true,
"disallowKeywords": [
"with"
],
"disallowMultipleLineStrings": true,
"disallowMultipleLineBreaks": true,
"validateLineBreaks": "LF",
"validateQuoteMarks": "'",
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"disallowKeywordsOnNewLine": [
"else"
],
"requireLineFeedAtFileEnd": true,
"maximumLineLength": 78,
"requireCapitalizedConstructors": true,
"safeContextKeyword": "self",
"requireDotNotation": true,
"disallowYodaConditions": true,
"validateJSDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
}
}
2 changes: 2 additions & 0 deletions .mdastignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bower_components/
components/
10 changes: 10 additions & 0 deletions .mdastrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"plugins": [
"lint",
"github",
"yaml-config"
],
"settings": {
"bullet": "*"
}
}
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: node_js
script: npm run-script test-travis
node_js:
- '0.10'
- '0.11'
- '0.12'
- iojs
sudo: false
after_script: npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls
deploy:
provider: npm
email: tituswormer@gmail.com
api_key:
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=
on:
repo: wooorm/mdast-util-to-string
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 changes: 36 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "mdast-util-to-string",
"main": "mdast-util-to-string.js",
"description": "Utility to get the plain text content of a node",
"license": "MIT",
"keywords": [
"mdast",
"markdown",
"node",
"to",
"string",
"util",
"utility"
],
"repository": {
"type": "git",
"url": "https://github.com/wooorm/mdast-util-to-string.git"
},
"authors": [
"Titus Wormer <tituswormer@gmail.com>"
],
"ignore": [
".*",
"*.log",
"*.md",
"build/",
"components/",
"coverage/",
"node_modules/",
"build.js",
"index.js",
"test.js",
"component.json",
"package.json"
]
}
19 changes: 19 additions & 0 deletions component.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "mdast-util-to-string",
"version": "0.0.0",
"description": "Utility to get the plain text content of a node",
"license": "MIT",
"keywords": [
"mdast",
"markdown",
"node",
"to",
"string",
"util",
"utility"
],
"repository": "wooorm/mdast-util-to-string",
"scripts": [
"index.js"
]
}
6 changes: 6 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
mdast:
setext: true
---

<!--lint disable no-multiple-toplevel-headings-->
41 changes: 41 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer. All rights reserved.
* @module mdast-util-to-string
* @fileoverview Utility to get the text value of a node.
*/

'use strict';

/**
* Get the value of `node`. Checks, `value`,
* `alt`, and `title`, in that order.
*
* @param {Node} node - Node to get the internal value of.
* @return {string} - Textual representation.
*/
function valueOf(node) {
return node &&
(node.value ? node.value :
(node.alt ? node.alt : node.title)) || '';
}

/**
* Returns the text content of a node. If the node itself
* does not expose plain-text fields, `toString` will
* recursivly try its children.
*
* @param {Node} node - Node to transform to a string.
* @return {string} - Textual representation.
*/
function toString(node) {
return valueOf(node) ||
(node.children && node.children.map(toString).join('')) ||
'';
}

/*
* Expose.
*/

module.exports = toString;
Loading

0 comments on commit 472a7ab

Please sign in to comment.