<commit_before># extract-svg-path

[![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges)

Extracts a string of subpaths from an svg file as a single path. Concats the `<path>` elements' data together to produce the output. This is mostly useful for SVG files of a single monotone shape or glyph (as opposed to, say, SVG font libraries or a complex SVG scene composed of several shapes). 

```npm install -g extract-svg-path```

```
extract-svg-path foo.svg > foo.txt
```

Now you can use the path alongside `parse-svg-path` and similar modules.

Use `-q` or `--quote` to escape the string for JSON:

```
extract-svg-path foo.svg --quote > foo.json
```

## API

[![NPM](https://nodei.co/npm/extract-svg-path.png)](https://nodei.co/npm/extract-svg-path/)

The API is intentionally dumbed down to make it easier for static analysis (i.e. bundler transforms).

```js
var contents = require('extract-svg-path')(__dirname + '/file.svg')
```

#### `extractSvgPath(file[, opt])`

Extracts the SVG contents of the given file path, using `fs.readFileSync` with utf8 by default. Any options will be passed along to [cheerio](https://github.com/cheeriojs/cheerio), but with `xmlMode` default to true. Additional options:

- `encoding` the file encoding, defaults to utf8

#### `extractSvgPath.extract(contents)`

Performs the cheerio extraction on a string.


## Browser API

Only `require('extract-svg-path').extract` will run by default in the browser. This can accept either a string (i.e. from [xhr](https://www.npmjs.org/package/xhr) response) or an SVG node (i.e. from [load-svg](https://github.com/substack/load-svg)).

```js
var parse = require('parse-svg-path')
var load = require('load-svg')
load('svg/infinity.svg', function(err, svg) {
    var paths = parse(extract(svg))
})
```

You can, however, use [extractify-svg-path](https://www.npmjs.org/package/extractify-svg-path), a browserify transform to inline calls to SVG files. Example:

```js
var parse = require('parse-svg-path')
var svg = require('extract-svg-path')(__dirname + '/shape.svg')
var path = parse(svg)
```

## commonjs

Using the command-line tool, you can pipe [module-exports](https://www.npmjs.org/package/module-exports) to produce a CommonJS file:

```
extract-svg-path foo.svg -q | module-exports > foo.js
```

Will produce:

```js
module.exports = "M50,1.42C23.213,1.42,1.........";
```

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/extract-svg-path/blob/master/LICENSE.md) for details.
<commit_msg>version bump<commit_after># extract-svg-path

[![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges)

Extracts a string of subpaths from an svg file as a single path. Concats the `<path>` elements' data together to produce the output. This is mostly useful for SVG files of a single monotone shape or glyph (as opposed to, say, SVG font libraries or a complex SVG scene composed of several shapes). 

```npm install -g extract-svg-path```

```
extract-svg-path foo.svg > foo.txt
```

Now you can use the path alongside `parse-svg-path` and similar modules.

Use `-q` or `--quote` to escape the string for JSON:

```
extract-svg-path foo.svg --quote > foo.json
```

## API

[![NPM](https://nodei.co/npm/extract-svg-path.png)](https://nodei.co/npm/extract-svg-path/)

The API is intentionally dumbed down to make it easier for static analysis (i.e. bundler transforms).

```js
var contents = require('extract-svg-path')(__dirname + '/file.svg')
```

#### `extractSvgPath(file[, opt])`

Extracts the SVG contents of the given file path, using `fs.readFileSync` with utf8 by default. Any options will be passed along to [cheerio](https://github.com/cheeriojs/cheerio), but with `xmlMode` default to true. Additional options:

- `encoding` the file encoding, defaults to utf8

#### `extractSvgPath.extract(contents)`

Performs the cheerio extraction on a string.


## Browser API

Only `require('extract-svg-path').extract` will run by default in the browser. This can accept either a string (i.e. from [xhr](https://www.npmjs.org/package/xhr) response) or an SVG node (i.e. from [load-svg](https://github.com/substack/load-svg)).

```js
var parse = require('parse-svg-path')
var extract = require('extract-svg-path').extract
var load = require('load-svg')
load('svg/infinity.svg', function(err, svg) {
    var paths = parse(extract(svg))
})
```

You can, however, use [extractify-svg-path](https://www.npmjs.org/package/extractify-svg-path), a browserify transform to inline calls to SVG files. Example:

```js
var parse = require('parse-svg-path')
var svg = require('extract-svg-path')(__dirname + '/shape.svg')
var path = parse(svg)
```

## commonjs

Using the command-line tool, you can pipe [module-exports](https://www.npmjs.org/package/module-exports) to produce a CommonJS file:

```
extract-svg-path foo.svg -q | module-exports > foo.js
```

Will produce:

```js
module.exports = "M50,1.42C23.213,1.42,1.........";
```

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/extract-svg-path/blob/master/LICENSE.md) for details.

{'fraction_non_alphanumeric': 0.156413739569183, 'fraction_numerical': 0.006209974771977489, 'mean_word_length': 4.307929969104016, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 14, 'lorem ipsum': 0, 'www.': 6, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5841933', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1656, 'n_words': 516}