mdast-util-to-string
Advanced tools
Comparing version 1.0.4 to 1.0.5
18
index.js
@@ -1,5 +0,4 @@ | ||
'use strict'; | ||
'use strict' | ||
/* Expose. */ | ||
module.exports = toString; | ||
module.exports = toString | ||
@@ -10,5 +9,7 @@ /* Get the text content of a node. If the node itself | ||
function toString(node) { | ||
return valueOf(node) || | ||
return ( | ||
valueOf(node) || | ||
(node.children && node.children.map(toString).join('')) || | ||
''; | ||
'' | ||
) | ||
} | ||
@@ -19,6 +20,5 @@ | ||
function valueOf(node) { | ||
if (!node) { | ||
return ''; | ||
} | ||
return node.value ? node.value : (node.alt ? node.alt : node.title) || ''; | ||
return ( | ||
(node && node.value ? node.value : node.alt ? node.alt : node.title) || '' | ||
) | ||
} |
{ | ||
"name": "mdast-util-to-string", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Utility to get the plain text content of a node", | ||
@@ -15,3 +15,3 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/syntax-tree/mdast-util-to-string", | ||
"repository": "syntax-tree/mdast-util-to-string", | ||
"bugs": "https://github.com/syntax-tree/mdast-util-to-string/issues", | ||
@@ -27,22 +27,30 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"devDependencies": { | ||
"browserify": "^14.0.0", | ||
"esmangle": "^1.0.0", | ||
"nyc": "^11.0.0", | ||
"remark-cli": "^3.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
"browserify": "^16.0.0", | ||
"nyc": "^12.0.0", | ||
"prettier": "^1.14.2", | ||
"remark-cli": "^5.0.0", | ||
"remark-preset-wooorm": "^4.0.0", | ||
"tape": "^4.4.0", | ||
"xo": "^0.18.2" | ||
"tinyify": "^2.4.3", | ||
"xo": "^0.22.0" | ||
}, | ||
"scripts": { | ||
"build-md": "remark . --quiet --frail --output", | ||
"build-bundle": "browserify index.js --no-builtins -s mdastUtilToString > mdast-util-to-string.js", | ||
"build-mangle": "esmangle mdast-util-to-string.js > mdast-util-to-string.min.js", | ||
"build": "npm run build-md && npm run build-bundle && npm run build-mangle", | ||
"lint": "xo", | ||
"test-api": "node test.js", | ||
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix", | ||
"build-bundle": "browserify . -s mdastUtilToString > mdast-util-to-string.js", | ||
"build-mangle": "browserify . -s mdastUtilToString -p tinyify > mdast-util-to-string.min.js", | ||
"build": "npm run build-bundle && npm run build-mangle", | ||
"test-api": "node test", | ||
"test-coverage": "nyc --reporter lcov tape test.js", | ||
"test": "npm run build && npm run lint && npm run test-coverage" | ||
"test": "npm run format && npm run build && npm run test-coverage" | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
}, | ||
"xo": { | ||
"space": true, | ||
"prettier": true, | ||
"esnext": false, | ||
@@ -49,0 +57,0 @@ "ignore": [ |
@@ -16,11 +16,11 @@ # mdast-util-to-string [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat] | ||
```js | ||
var unified = require('unified'); | ||
var parse = require('remark-parse'); | ||
var toString = require('mdast-util-to-string'); | ||
var unified = require('unified') | ||
var parse = require('remark-parse') | ||
var toString = require('mdast-util-to-string') | ||
var tree = unified() | ||
.use(parse) | ||
.parse('Some _emphasis_, **importance**, and `code`.'); | ||
.parse('Some _emphasis_, **importance**, and `code`.') | ||
console.log(toString(tree)); //=> 'Some emphasis, importance, and code.' | ||
console.log(toString(tree)) // => 'Some emphasis, importance, and code.' | ||
``` | ||
@@ -50,2 +50,10 @@ | ||
## Contribute | ||
See [`contributing.md` in `syntax-tree/mdast`][contributing] for ways to get | ||
started. | ||
This organisation has a [Code of Conduct][coc]. By interacting with this | ||
repository, organisation, or community you agree to abide by its terms. | ||
## License | ||
@@ -69,3 +77,3 @@ | ||
[license]: LICENSE | ||
[license]: license | ||
@@ -79,1 +87,5 @@ [author]: http://wooorm.com | ||
[strip-markdown]: https://github.com/wooorm/strip-markdown | ||
[contributing]: https://github.com/syntax-tree/mdast/blob/master/contributing.md | ||
[coc]: https://github.com/syntax-tree/mdast/blob/master/code-of-conduct.md |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
5860
88
8