Giter VIP home page Giter VIP logo

mathjax-node-sre's Introduction

mathjax-node-sre Build Status

Greenkeeper badge

This module extends mathjax-node using speech-rule-engine.

It can be used as a drop-in replacement for mathjax-node.

Use

npm install mathjax-node-sre

to install mathjax-node-sre and its dependencies.

features

mathjax-node-sre provides three features.

drop-in replacement for mathjax-node

mathjax-node-sre can be used as a drop-in replacement of mathjax-node, so just import start, config, and typeset as you would with mathjax-node.

In addition to the usual mathjax-node configuration options, mathjax-node-sre accepts

speakText: false,               // adds spoken annotations to output
speakRuleset: "mathspeak",      // set speech ruleset; default (= chromevox rules) or mathspeak
speakStyle: "default",          // set speech style for mathspeak rules:  default, brief, sbrief)
semantic: false,                // adds semantic tree information to output
minSTree: false,                // if true the semantic tree is minified
enrich: false                   // replace the math input with MathML resulting from SRE enrichment
speech: 'deep'                  // sets depth of speech; 'shallow' or 'deep'

post-processor

mathjax-node-sre provides a postprocessor which expects mathjax-node output together with a configuration object containing the above options (except enrich) to add speech-text to mathjax-node output.

For example,

const mj = require('mathjax-node').typeset;
const postprocessor = require('mathjax-node-sre').postprocessor;

mj({math: 'x + y', format: "TeX", mml: true},function(result){
  postprocessor({speakText: true}, result, function(output){
    console.log(output.speakText) // => x plus y
  })
});

pre-processor

mathjax-node-sre provides a preprocessor which expects mathjax-node input and replaces the input with the result of (if necessary converting to) MathML and enriching the MathML with SRE.

For example:

var preprocessor = require('mathjax-node-sre').preprocessor;
preprocessor({ math: 'x^2', format: "TeX"}, function(output){
    console.log(output.math) // => <math xmlns="http://www.w3.org/1998/Math/MathML" display="block" alttext="x^2"><msup data-semantic-type="superscript" data-semantic-role="latinletter" data-semantic-id="2" data-semantic-children="0,1"><mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-id="0" data-semantic-parent="2">x</mi><mn data-semantic-type="number" data-semantic-role="integer" data-semantic-font="normal" data-semantic-id="1" data-semantic-parent="2">2</mn></msup></math>
})

mathjax-node-sre's People

Contributors

dependabot[bot] avatar greenkeeper[bot] avatar pkra avatar zorkow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mathjax-node-sre's Issues

remove extraneous uses of jsdom

Following #15, we need to theoretically update our use of jsdom to the new API.

However, we only use it once (in the test for #1) which may as well be a regexp (especially since the underlying jsdom bug seems fixed in jsdom now).

pretty-print SVG output

mathjax-node applies

 var svgdata = svg.outerHTML.replace(/><([^/])/g,">\n<$1")
                               .replace(/(<\/[a-z]*>)(?=<\/)/g,"$1\n")
                               .replace(/(<(?:use|image) [^>]*)(href=)/g,' $1xlink:$2');

but we do not.

npm package fails

Does not work with latest version of yargs (10.1.1).
No real minimal example, just node ./bin/mjsre.js

[svg output] href lack xlink prefix

Since we serialize the svgnode from mathjax-node (after modifying the speechtext), we need to add the xlink prefix (like mathjax-node does).

An in-range update of yargs is breaking the build 🚨

The dependency yargs was updated from 13.2.2 to 13.2.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

yargs is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 14 commits.

  • a6e67f1 chore(release): 13.2.4
  • fc13476 chore: update standard-verison dependency
  • bf46813 fix(i18n): rename unclear 'implication failed' to 'missing dependent arguments' (#1317)
  • a3a5d05 docs: fix a broken link to MS Terminology Search (#1341)
  • b4f8018 build: add .versionrc that hides test/build
  • 0c39183 chore(release): 13.2.3
  • 08e0746 chore: update deps (#1340)
  • 843e939 docs: make --no- boolean prefix easier to find in the docs (#1338)
  • 84cac07 docs: restore removed changelog of v13.2.0 (#1337)
  • b20db65 fix(deps): upgrade cliui for compatibility with latest chalk. (#1330)
  • c294d1b test: accept differently formatted output (#1327)
  • ac3f10c chore: move .hbs templates into .js to facilitate webpacking (#1320)
  • 0295132 fix: address issues with dutch translation (#1316)
  • 9f2468e doc: clarify parserConfiguration object structure (#1309)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

upcoming archival of this repository

MathJax v3 is out and works in NodeJS as it does in the browser.

At some point in the not too distant future, I will archive this repository.

preprocessor should not disable speaktext

It's not necessary or useful to disable speakText in the output. If the result was processed with MathJax(-node), it would simply re-use the speakText by default.

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.