Giter Site home page Giter Site logo

insert-equations's Introduction

insert-equations

NPM version Build Status Coverage Status Dependencies

Parse README.md files and turn LaTeX equations into SVGs.

Installation

$ npm install insert-equations

Usage

var insertEquations = require( 'insert-equations' );

insertEquations( dir, clbk )

Parses the README.md file in the supplied directory and inserts SVG images for all <equation> 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.

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

    <!-- <equation class="equation" label="eq:gamma_function_positive_integers" align="center" raw="\Gamma ( n ) = (n-1)!" alt="Gamma function for positive integers."> -->
    <!-- </equation> -->

    will be transformed to

    <!-- <equation class="equation" label="eq:gamma_function_positive_integers" align="center" raw="\Gamma ( n ) = (n-1)!" alt="Gamma function for positive integers."> -->
    <div class="equation" align="center" data-raw-text="\Gamma ( n ) = (n-1)!" data-equation="eq:gamma_function_positive_integers">
    	<img src="https://cdn.rawgit.com/Planeshifter/insert-equations-examples/8fd73c14a23a0bcb1d31e7e3246ae411e11a0c70/docs/img/eqn1.svg" alt="Gamma function for positive integers.">
    	<br>
    </div>
    <!-- </equation> -->
  • 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

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,

$ node ./examples/index.js

CLI

Installation

To use the module as a general utility, install the module globally

$ npm install -g insert-equations

Usage

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

$ insert-equations examples/fixtures

Tests

Unit

This repository uses tape for unit tests. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

Browser Support

This repository uses Testling for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:

$ make test-browsers

To view the tests in a local web browser,

$ make view-browser-tests

License

MIT license.

Copyright

Copyright © 2016. Philipp Burckhardt.

insert-equations's People

Contributors

planeshifter avatar

Stargazers

timelyportfolio avatar Ricky Reusser avatar

Watchers

Ricky Reusser avatar timelyportfolio avatar James Cloos avatar  avatar Athan avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.