This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `$ npm install speech-rule-engine` | |
var sre = require('speech-rule-engine'); | |
var mathml = '<math xmlns="http://www.w3.org/1998/Math/MathML"> <mfrac> <mn>1</mn> <mn>2</mn> </mfrac> </math>'; | |
sre.setupEngine({semantics: true, domain: "mathspeak", style: "brief"}); | |
console.log(sre.processExpression(mathml)); | |
// one-half |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: python sre.py mml.txt | |
import os | |
import sys | |
from execjs import get | |
runtime = get('Node') | |
context = runtime.compile(''' | |
module.paths.push('%s'); | |
var sre = require('speech-rule-engine'); | |
sre.setupEngine({semantics: true, domain: "mathspeak", style: "brief"}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var mjAPI = require("./lib/main"); | |
var fs = require('fs'); | |
var inputFile = "file.txt"; // use xargs or something | |
var output = []; | |
var array = fs.readFileSync('file.txt').toString().split("\n"); | |
mjAPI.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var mjAPI = require('mathjax-node/lib/mj-single'); | |
var typeset = mjAPI.typeset; | |
var fs = require('fs'); | |
var libxmljs = require('libxmljs'); | |
var argv = require('yargs') | |
.strict() | |
.usage('Usage: jats -i input.html -o output.html -f HTML', { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mjAPI = require("../lib/main.js"); | |
var svg2png = require('svg2png'); | |
function createPNG(result, callback){ | |
var sourceBuffer = new Buffer(result.svg, "utf-8"); | |
svg2png(sourceBuffer).then(function(buffer){ | |
result.png = "data:image/png;base64," + buffer.toString('base64'); | |
return callback(result); | |
}) | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
grunt.initConfig({ | |
'json-minify': { | |
build: { | |
files: 'dist/mathmaps/**/*.json' | |
} | |
}, | |
gitclone: { | |
'speech-rule-engine': { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var mjAPI = require("../lib/main.js"); | |
mjAPI.start(); | |
var jsdom = require('jsdom').jsdom; | |
var serializeDocument = require("jsdom").serializeDocument; | |
var input = "<!DOCTYPE html><p> When <math> <mi>a</mi><mo>≠</mo><mn>0</mn> </math>, there are two solutions to <math> <mi>a</mi><msup><mi>x</mi><mn>2</mn></msup> <mo>+</mo> <mi>b</mi><mi>x</mi> <mo>+</mo> <mi>c</mi> <mo>=</mo> <mn>0</mn> </math></p>"; | |
var document = jsdom(input); | |
var window = document.defaultView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>MathJax even more basic pen</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var images = document.getElementsByTagName('img'); | |
var hasMath = false; | |
for (var i = 0; i < images.length; i++){ | |
var image = images[i]; | |
tex = image.getAttribute('alt'); | |
if (tex && tex[0] === '$'){ // TODO a class for TeX images would be cleaner, also to differentiate inline and display math | |
hasMath = true; | |
var preview = document.createElement('span'); | |
preview.setAttribute('class','MathJax_Preview'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var images = document.querySelectorAll('img.latex'); | |
for (var i = 0; i < images.length; i++){ | |
var image = images[i]; | |
tex = image.getAttribute('alt'); | |
var preview = document.createElement('span'); | |
preview.setAttribute('class','MathJax_Preview'); | |
image.parentNode.insertBefore(preview, image); | |
preview.appendChild(image); | |
var script = document.createElement('script'); |