<commit_before># svg-to-jsx

Simple module that consumes SVG and spits out JSX. As simple as that.

## Installation

`svg-to-jsx` is a node module. To install you have to have Node.js and NPM installed on your machine.

	npm install svg-to-jsx
	
## Usage

You can either use the module in your Node.js project or via command line.

### Use as a node module

	var fs = require('fs');
	var svgtojsx = require('svg-to-jsx');
	
	var svg = fs.readFileSync('<your SVG file>');
	var options = {};
	
	svgtojsx(svg, function(error, jsx) {
		// jsx variable now contains your JSX string
	});
		
	# Options can be passed as a second argument
	svgtojsx(svg, options, function(error, jsx) {
		// jsx variable now contains your JSX string
	});
	
#### Options

`root` *String* In case you only want to output single SVG element you can set this to its ID.

### Use from command line

	# To output JSX to stdout
	$ svg-to-jsx <path to an SVG file>
	
	# To display usage info
	$ svg-to-jsx --help
	$ svg-to-jsx -h
	
	# To output to file
	$ svg-to-jsx -o <path to JSX file> <path to an SVG file>
	
## Testing

To run unit test just execute

	npm test<commit_msg>Add docs for refs and passProps<commit_after># svg-to-jsx

Simple module that consumes SVG and spits out JSX. As simple as that.

## Installation

`svg-to-jsx` is a node module. To install you have to have Node.js and NPM installed on your machine.

	npm install svg-to-jsx

## Usage

You can either use the module in your Node.js project or via command line.

### Use as a node module

	var fs = require('fs');
	var svgtojsx = require('svg-to-jsx');

	var svg = fs.readFileSync('<your SVG file>');
	var options = {};

	svgtojsx(svg, function(error, jsx) {
		// jsx variable now contains your JSX string
	});

	# Options can be passed as a second argument
	svgtojsx(svg, options, function(error, jsx) {
		// jsx variable now contains your JSX string
	});

#### Options

`root` *String* In case you only want to output single SVG element you can set this to its ID.

`passProps` *Boolean* Set this to true in case you want to pass `props` to the root element.

`refs` *Object* In case you want to be able to access specific elements from your SVG file, you can add `refs` to them. This object's keys are IDs of elements that will be assigned `refs`, the values are the `ref` names, for example:

    {
        mySvgElement: 'refToMySvgElement'
    }

will result in element with ID `mySvgElement` to be accessible via `this.refs.refToMySvgElement`.

### Use from command line

	# To output JSX to stdout
	$ svg-to-jsx <path to an SVG file>

	# To display usage info
	$ svg-to-jsx --help
	$ svg-to-jsx -h

	# To output to file
	$ svg-to-jsx -o <path to JSX file> <path to an SVG file>

## Testing

To run unit test just execute

	npm test
{'fraction_non_alphanumeric': 0.0960431654676259, 'fraction_numerical': 0.0, 'mean_word_length': 3.304953560371517, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3559474', 'n_tokens_mistral': 976, 'n_tokens_neox': 929, 'n_words': 410}