| Path: | README |
| Last Update: | Thu Sep 15 17:29:12 EDT 2005 |
| Author: | William Morgan (mailto: wmorgan-ritex@masanjin.net) |
| Copyright: | Copyright 2005 William Morgan |
| License: | GNU GPL version 2 |
Ritex converts expressions from WebTeX into MathML. WebTeX is an adaptation of TeX math syntax for web display.
Ritex makes inserting math into HTML pages easy. It supports most TeX math syntax as well as macros.
For example, Ritex turns
\alpha^\beta
into
<math xmlns="http://www.w3.org/1998/Math/MathML">
<msup>
<mi>α</mi>
<mi>β</mi>
</msup>
</math>
Ritex is based heavily on itex2mml (pear.math.pitt.edu/mathzilla/itex2mmlItex.html), a popular TeX math to MathML convertor—so much so that the default correct answer to unit tests is to do whatever itex2mml does!
Ritex features several advantages over itex2mml:
Use RubyGems. gem install ritex
For CVS access, see the Rubyforge page: rubyforge.org/projects/ritex.
require 'rubygems'
require 'ritex'
p = Ritex::Parser.new
ARGF.each { |l| puts p.parse(l) }
## or ...
ARGF.each do |l|
begin
puts p.parse(l)
rescue Racc::ParseError
$stderr.puts "invalid input"
end
end
Calling Ritex from Ruby is very simple. If the synopsis above isn’t enough, see the documentation for Ritex::Parser for the gory details.
Ritex parses WebTeX. WebTeX is an adapation of the TeX math syntax which is designed for web page display. The WebTeX documentation can be found at stuff.mit.edu/afs/athena/software/webeq/currenthome/docs/webtex/toc.html.
If you’re familiar with TeX math syntax, you’ll feel right at home. But there are several important differences between it and WebTeX. Most notably:
These differences are explained in the WebTeX documentation.
Ritex is based heavily on Itex2mml. Itex2mml accepts what it calls "Itex", an extension of WebTeX which adds a few aliases (like \infinity for \infty) and markups (like \underoverset). Ritex supports these extensions. Regardless, I’ve chosen to say that Ritex parses WebTeX rather than Itex, mainly because the former includes macros and is better documented.
Itex is described at pear.math.pitt.edu/mathzilla/itex2mmlItex.html.
See the ReleaseNotes for features in WebTeX that are currently unimplemented in Ritex.
If you’re familiar with itex2mml, there are a few subtle differences between the two: