# -*- mode: Perl -*-
# /=====================================================================\ #
# |  texvc                                                              | #
# | LaTeXML Bindings for simulating texvc                               | #
# |=====================================================================| #
# | Part of LaTeXML:                                                    | #
# |  Public domain software, produced as part of work done by the       | #
# |  United States Government & not subject to copyright in the US.     | #
# |---------------------------------------------------------------------| #
# | Bruce Miller <bruce.miller@nist.gov>                        #_#     | #
# | http://dlmf.nist.gov/LaTeXML/                              (o o)    | #
# \=========================================================ooo==U==ooo=/ #
package LaTeXML::Package::Pool;
use strict;
use warnings;
use LaTeXML::Package;

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# MediaWiki installations, like Wikipedia, often use texvc to convert
# latex-like math to images. It acts as a filter and/or wrapper
# that then calls latex to process some(?) of it's markup.
# The markup that texvc accepts doesn't seem to correspond to a specific list
# of standard TeX/LaTeX packages, but seems to consist of whatever the author
# found useful. See
#    http://meta.wikimedia.org/wiki/TeX
# for a listing of the commands it recognizes.
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# This texvc.sty.ltxml package will attempt to cover the markup that texvc
# recognizes --- there is no regular LaTeX texvc.sty, that I am aware of.

RequirePackage('amsmath');
RequirePackage('amsfonts');
RequirePackage('amssymb');
RequirePackage('xcolor', options => ['dvipsnames', 'usenames']);
# TODO: we need teubner.sty
RequirePackage('eurosym');
RequirePackage('cancel');

DefMathI('\sgn', undef, "sgn", role => 'OPFUNCTION', meaning => 'sign');

Let('\part', '\partial');    # Normally for sectioning
Let('\and',  '\land');       # Normally for frontmatter

# Also, equation numbering appears to be turned off.
#AssignValue(EQUATIONGROUP_NUMBER=>0);
#AssignValue(EQUATIONROW_NUMBER=>0);
Let('\@equationgroup@number', '\nonumber');

# MathJax allows an explicit \unicode character specification, as seen in StackExchange:
# λ (\unicode{x00C5}) for λ (Å)
# Documentation:
# http://docs.mathjax.org/en/latest/input/tex/extensions/unicode.html
DefPrimitive('\unicode[][]{}', sub {
    my $code = ToString($_[3]);
    if ($code =~ /^x/) {
      $code = hex $code }
    else {
      $code = int($code); }
    my $code_char = UTF($code);
    return Box($code_char, undef, undef,
      T_OTHER($code_char)); });

#======================================================================
# Uppercase Greek (the ones not already defined in TeX)
DefMathI('\Alpha', undef, "\x{0391}");
DefMathI('\Beta',  undef, "\x{0392}");
#DefMathI('\Gamma',     undef,"\x{0393}");
#DefMathI('\Delta',     undef,"\x{0394}");
DefMathI('\Epsilon', undef, "\x{0395}");
DefMathI('\Zeta',    undef, "\x{0396}");
DefMathI('\Eta',     undef, "\x{0397}");
#DefMathI('\Theta',     undef,"\x{0398}");
DefMathI('\Iota',  undef, "\x{0399}");
DefMathI('\Kappa', undef, "\x{039A}");
#DefMathI('\Lambda',    undef,"\x{039B}");
DefMathI('\Mu', undef, "\x{039C}");
DefMathI('\Nu', undef, "\x{039D}");
#DefMathI('\Xi',        undef,"\x{039E}");
DefMath('\omicron', "\x{03BF}");
DefMathI('\Omicron', undef, "\x{039F}");

#DefMathI('\Pi',        undef,"\x{03A0}");
DefMathI('\Rho', undef, "\x{03A1}");
#DefMathI('\Sigma',     undef,"\x{03A3}");
DefMathI('\Tau', undef, "\x{03A4}");
#DefMathI('\Upsilon',   undef,"\x{03A5}");
#DefMathI('\Phi',       undef,"\x{03D5}");
DefMathI('\Chi', undef, "\x{03A7}");
#DefMathI('\Psi',       undef,"\x{03A8}");
#DefMathI('\Omega',     undef,"\x{03A9}");
#======================================================================
# Archaic(?) greek
DefMathI('\Digamma', undef, "\x{03DC}");    # GREEK LETTER DIGAMMA
DefMathI('\digamma', undef, "\x{03DD}");    # GREEK SMALL LETTER DIGAMMA

# Is this the intent, here???
DefMathI('\Coppa',    undef, "\x{03D8}");    # GREEK LETTER ARCHAIC KOPPA
DefMathI('\coppa',    undef, "\x{03D9}");    # GREEK SMALL LETTER ARCHAIC KOPPA
DefMathI('\varcoppa', undef, "\x{03D9}");    # GREEK SMALL LETTER ARCHAIC KOPPA
DefMathI('\Koppa',    undef, "\x{03DE}");    # GREEK LETTER KOPPA
DefMathI('\koppa',    undef, "\x{03DF}");    # GREEK SMALL LETTER KOPPA

DefMathI('\Stigma',    undef, "\x{03DA}");   # GREEK LETTER STIGAM
DefMathI('\stigma',    undef, "\x{03DB}");   # GREEK SMALL LETTER STIGMA
DefMathI('\varstigma', undef, "\x{03DB}");   # GREEK SMALL LETTER STIGMA

DefMathI('\Sampi', undef, "\x{03E0}");       # GREEK LETTER SAMPI
DefMathI('\sampi', undef, "\x{03E1}");       # GREEK SMALL LETTER SAMPI

#======================================================================
# Spanish sine
DefMathI('\sen', undef, "sen", role => 'TRIGFUNCTION', meaning => 'sine');
#======================================================================

# texvc.sty, 2015 by Moritz Schubotz

# -- already in amssymb, ignore:
# DefMacroI('\doublecup',undef,'\Cup');
# DefMacroI('\gggtr',undef,'\ggg');
# DefMacroI('\restriction', undef, '\upharpoonright');

DefMacroI('\darr',      undef, '\downarrow');
DefMacroI('\dArr',      undef, '\Downarrow');
DefMacroI('\Darr',      undef, '\Downarrow');
DefMacroI('\lang',      undef, '\langle');
DefMacroI('\rang',      undef, '\rangle');
DefMacroI('\uarr',      undef, '\uparrow');
DefMacroI('\uArr',      undef, '\Uparrow');
DefMacroI('\Uarr',      undef, '\Uparrow');
DefMacroI('\H',         undef, '\mathbb{H}');
DefMacroI('\N',         undef, '\mathbb{N}');
DefMacroI('\Q',         undef, '\mathbb{Q}');
DefMacroI('\R',         undef, '\mathbb{R}');
DefMacroI('\Z',         undef, '\mathbb{Z}');
DefMacroI('\alef',      undef, '\aleph');
DefMacroI('\alefsym',   undef, '\aleph');
DefMacroI('\ang',       undef, '\angle');
DefMacroI('\bull',      undef, '\bullet');
DefMacroI('\clubs',     undef, '\clubsuit');
DefMacroI('\cnums',     undef, '\mathbb{C}');
DefMacroI('\Complex',   undef, '\mathbb{C}');
DefMacroI('\Dagger',    undef, '\ddagger');
DefMacroI('\diamonds',  undef, '\diamondsuit');
DefMacroI('\Doteq',     undef, '\doteqdot');
DefMacroI('\doublecap', undef, '\Cap');
DefMacroI('\empty',     undef, '\emptyset');
DefMacroI('\exist',     undef, '\exists');
DefMacroI('\ge',        undef, '\geq');
DefMacroI('\hAar',      undef, '\Leftrightarrow');
DefMacroI('\harr',      undef, '\leftrightarrow');
DefMacroI('\Harr',      undef, '\Leftrightarrow');
DefMacroI('\hearts',    undef, '\heartsuit');
DefMacroI('\image',     undef, '\Im');
DefMacroI('\infin',     undef, '\infty');
DefMacroI('\isin',      undef, '\in');
DefMacroI('\larr',      undef, '\leftarrow');
DefMacroI('\Larr',      undef, '\Leftarrow');
DefMacroI('\lArr',      undef, '\Leftarrow');
DefMacroI('\le',        undef, '\leq');
DefMacroI('\lrarr',     undef, '\leftrightarrow');
DefMacroI('\Lrarr',     undef, '\Leftrightarrow');
DefMacroI('\lrArr',     undef, '\Leftrightarrow');
DefMacroI('\natnums',   undef, '\mathbb{N}');
DefMacroI('\ne',        undef, '\neq');
DefMacroI('\O',         undef, '\emptyset');
DefMacroI('\plusmn',    undef, '\pm');
DefMacroI('\rarr',      undef, '\rightarrow');
DefMacroI('\Rarr',      undef, '\Rightarrow');
DefMacroI('\rArr',      undef, '\Rightarrow');
DefMacroI('\real',      undef, '\Re');
DefMacroI('\reals',     undef, '\mathbb{R}');
DefMacroI('\Reals',     undef, '\mathbb{R}');
DefMacroI('\sdot',      undef, '\cdot');
DefMacroI('\sect',      undef, '\S');
DefMacroI('\spades',    undef, '\spadesuit');
DefMacroI('\sub',       undef, '\subset');
DefMacroI('\sube',      undef, '\subseteq');
DefMacroI('\supe',      undef, '\supseteq');
DefMacroI('\thetasym',  undef, '\vartheta');
DefMacroI('\varcoppa',  undef, '\mbox{\coppa}');
DefMacroI('\weierp',    undef, '\wp');

1;