Generate an HTML string for displaying an SVG equation in a Github Markdown file.
npm install github-markdown-equation-elementEquation Element
===
[![NPM version][npm-image]][npm-url] [![Build Status][build-image]][build-url] [![Coverage Status][coverage-image]][coverage-url] [![Dependencies][dependencies-image]][dependencies-url]
> Generate an HTML string for displaying an SVG equation in a Github Markdown file.
`` bash`
$ npm install github-markdown-equation-element
` javascript`
var createElement = require( 'github-markdown-equation-element' );
#### createElement( [options] )
Generate an HTML string for displaying an SVG equation in a Github Markdown file.
` javascript`
var html = createElement();
/* returns
''
*/
The function accepts the following options:'equation'
* __className__: element class name. Default: .'center'
* __align__: element alignment. Default: .
* __raw__: raw equation text.
* __label__: equation label.
* __src__: image source URL.
* __alt__: alternative image text.
Each option corresponds an HTML attribute. For example, to set the image source URL, set the src option.
` javascript
var opts = {
'src': 'https://cdn.rawgit.com/math-io/gamma/master/docs/img/eqn1.svg'
};
var html = createElement( opts );
/* returns
'
To include a raw equation [TeX][tex] or [LaTeX][latex]
string in the element, set the raw option.` javascript
var opts = {
'raw': '\\Gamma ( n ) = (n-1)!',
'src': 'https://cdn.rawgit.com/math-io/gamma/master/docs/img/eqn1.svg'
};var html = createElement( opts );
/* returns
'

'
*/
`
Examples
` javascript
var createElement = require( 'github-markdown-equation-element' );var opts = {
'className': 'eqn',
'align': 'left',
'raw': '\\operatorname{erf}(x) = \\frac{2}{\\sqrt\\pi}\\int_0^x e^{-t^2}\\,\\mathrm dt',
'label': 'eq:erf',
'src': 'https://cdn.rawgit.com/math-io/erf/master/docs/img/eqn.svg',
'alt': 'Error function.'
};
var html = createElement( opts );
console.log( html );
/* returns
'

'
*/
`To run the example code from the top-level application directory,
` bash
$ node ./examples/index.js
`
---
CLI
$3
To use the module as a general utility, install the module globally
` bash
$ npm install -g github-markdown-equation-element
`
$3
` bash
Usage: gheqn [options]Options:
-h, --help Print this message.
-V, --version Print the package version.
--class name Element class name. Default: equation.
--align alignment Element alignment. Default: center.
--raw text Raw equation text.
--label label Equation label.
--src url Image source URL.
--alt text Alternative image text.
`
$3
` bash
$ gheqn --raw '\Gamma ( n ) = (n-1)!' --src 'https://cdn.rawgit.com/math-io/gamma/master/docs/img/eqn1.svg'
=> \n\t
\n\t
\n
`
---
Tests
$3
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.
$3
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
`
$3
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
``
---
Copyright © 2016. Athan Reines.
[npm-image]: http://img.shields.io/npm/v/github-markdown-equation-element.svg
[npm-url]: https://npmjs.org/package/github-markdown-equation-element
[build-image]: http://img.shields.io/travis/kgryte/github-markdown-equation-element/master.svg
[build-url]: https://travis-ci.org/kgryte/github-markdown-equation-element
[coverage-image]: https://img.shields.io/codecov/c/github/kgryte/github-markdown-equation-element/master.svg
[coverage-url]: https://codecov.io/github/kgryte/github-markdown-equation-element?branch=master
[dependencies-image]: http://img.shields.io/david/kgryte/github-markdown-equation-element.svg
[dependencies-url]: https://david-dm.org/kgryte/github-markdown-equation-element
[dev-dependencies-image]: http://img.shields.io/david/dev/kgryte/github-markdown-equation-element.svg
[dev-dependencies-url]: https://david-dm.org/dev/kgryte/github-markdown-equation-element
[github-issues-image]: http://img.shields.io/github/issues/kgryte/github-markdown-equation-element.svg
[github-issues-url]: https://github.com/kgryte/github-markdown-equation-element/issues
[tape]: https://github.com/substack/tape
[istanbul]: https://github.com/gotwarlost/istanbul
[testling]: https://ci.testling.com
[tex]: https://en.wikipedia.org/wiki/TeX
[latex]: https://en.wikipedia.org/wiki/LaTeX