https://github.com/planeshifter/insert-equations
Parse README.md files and turn LaTeX equations into SVGs.
https://github.com/planeshifter/insert-equations
Last synced: 9 months ago
JSON representation
Parse README.md files and turn LaTeX equations into SVGs.
- Host: GitHub
- URL: https://github.com/planeshifter/insert-equations
- Owner: Planeshifter
- License: mit
- Created: 2016-05-19T14:29:59.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-19T15:52:38.000Z (about 10 years ago)
- Last Synced: 2025-06-03T07:28:48.220Z (about 1 year ago)
- Language: JavaScript
- Size: 20.5 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
insert-equations
===
[![NPM version][npm-image]][npm-url] [![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url] [![Dependencies][dependencies-image]][dependencies-url]
> Parse README.md files and turn LaTeX equations into SVGs.
## Installation
``` bash
$ npm install insert-equations
```
## Usage
``` javascript
var insertEquations = require( 'insert-equations' );
```
#### insertEquations( dir, clbk )
Parses the `README.md` file in the supplied directory and inserts SVG images for all `` tags. The `label`, `align`, `raw` and `alt` attributes of the equation tag will be used. Upon creating the SVG images, the `README.md` file will be overwritten with the newly generated markup.
``` javascript
insertEquations( 'mydirectory', done )
function done( err ) {
if ( err ) {
throw err;
}
console.log( 'README.md file successfully processed.' );
} // end FUNCTION done()
```
## Notes
* As a concrete example
``` html
```
will be transformed to
``` html
```
* The supplied directory has to be a git project with a remote branch on GitHub. Otherwise, `insertEquations` will throw an error.
* Beware: `insertEquations` automatically creates a commit for the newly created files and changes to `README.md`.
## Examples
``` javascript
var child_process = require( 'child_process' );
var fs = require( 'fs-extra' );
var path = require( 'path' );
var insertEquations = require( 'insert-equations' );
var fPath = path.resolve( __dirname, './fixtures' );
var inputPath = path.join( fPath, '_README.md' );
var outputPath = path.join( fPath, 'README.md' );
fs.copySync( inputPath, outputPath );
child_process.execSync( 'rm -rf .git', { cwd: fPath } );
child_process.execSync( 'git init', { cwd: fPath } );
child_process.execSync( 'git remote add origin https://github.com/Planeshifter/insert-equations-examples.git', { cwd: fPath } );
insertEquations( fPath, done );
function done( err ) {
if ( err ) {
throw err;
}
console.log( 'README.md file successfully processed.' );
} // end FUNCTION done()
```
To run the example code from the top-level application directory,
``` bash
$ node ./examples/index.js
```
---
## CLI
### Installation
To use the module as a general utility, install the module globally
``` bash
$ npm install -g insert-equations
```
### Usage
``` bash
Usage: insert-equations [options] [directory]
Options:
-h, --help Print this message.
-V, --version Print the package version.
```
## Notes
* If no `directory` is supplied, the current working directory will be used to look for a `README.md` file.
### Examples
``` bash
$ insert-equations examples/fixtures
```
---
## Tests
### Unit
This repository uses [tape][tape] for unit tests. To run the tests, execute the following command in the top-level application directory:
``` bash
$ make test
```
All new feature development should have corresponding unit tests to validate correct functionality.
### Test Coverage
This repository uses [Istanbul][istanbul] as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
``` bash
$ make test-cov
```
Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report,
``` bash
$ make view-cov
```
### Browser Support
This repository uses [Testling][testling] for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:
``` bash
$ make test-browsers
```
To view the tests in a local web browser,
``` bash
$ make view-browser-tests
```
---
## License
[MIT license](http://opensource.org/licenses/MIT).
## Copyright
Copyright © 2016. Philipp Burckhardt.
[npm-image]: http://img.shields.io/npm/v/insert-equations.svg
[npm-url]: https://npmjs.org/package/insert-equations
[build-image]: http://img.shields.io/travis/Planeshifter/insert-equations/master.svg
[build-url]: https://travis-ci.org/Planeshifter/insert-equations
[coverage-image]: https://img.shields.io/codecov/c/github/Planeshifter/insert-equations/master.svg
[coverage-url]: https://codecov.io/github/Planeshifter/insert-equations?branch=master
[dependencies-image]: http://img.shields.io/david/Planeshifter/insert-equations.svg
[dependencies-url]: https://david-dm.org/Planeshifter/insert-equations
[dev-dependencies-image]: http://img.shields.io/david/dev/Planeshifter/insert-equations.svg
[dev-dependencies-url]: https://david-dm.org/dev/Planeshifter/insert-equations
[github-issues-image]: http://img.shields.io/github/issues/Planeshifter/insert-equations.svg
[github-issues-url]: https://github.com/Planeshifter/insert-equations/issues
[tape]: https://github.com/substack/tape
[istanbul]: https://github.com/gotwarlost/istanbul
[testling]: https://ci.testling.com