Ticket #9774: trac_9774-mathjax-try7.patch

File trac_9774-mathjax-try7.patch, 91.2 KB (added by kini, 8 years ago)

apply to $SAGE_ROOT/devel/sage

  • doc/common/builder.py

    # HG changeset patch
    # User J. H. Palmieri <palmieri@math.washington.edu>
    # Date 1326533960 -28800
    # Node ID c7da20717abe7fca1b0683eb5b5e0563e0fd8aa4
    # Parent  361d834fbcd60757f8d71f636c4c13d5dac1df6a
    #9774: switch Sage library from jsMath to MathJax.
    
    Many people helped in this patch, including: Rob Beezer, Davide Cervone,
    John Palmieri, Rado Kirov, Nathan Carter, and Jason Grout
    
    diff --git a/doc/common/builder.py b/doc/common/builder.py
    a b  
    791791    s += "    sage -docbuild -FDC all\n"
    792792    s += "    sage -docbuild constructions pdf\n"
    793793    s += "    sage -docbuild reference html -jv3\n"
    794     s += "    sage -docbuild --jsmath tutorial html\n"
     794    s += "    sage -docbuild --mathjax tutorial html\n"
    795795    s += "    sage -docbuild reference print_unincluded_modules\n"
    796796    s += "    sage -docbuild developer -j html --sphinx-opts -q,-aE --verbose 2"
    797797    return s
     
    964964                        default=False, action="store_true",
    965965                        help="include variables prefixed with '_' in reference manual; may be slow, may fail for PDF output")
    966966
    967     standard.add_option("-j", "--jsmath", dest="jsmath",
     967    standard.add_option("-j", "--mathjax", "--jsmath", dest="mathjax",
    968968                        action="store_true",
    969                         help="render math using jsMath; FORMATs: html, json, pickle, web")
     969                        help="render math using MathJax; FORMATs: html, json, pickle, web")
    970970    standard.add_option("--no-pdf-links", dest="no_pdf_links",
    971971                        action="store_true",
    972972                        help="do not include PDF links in DOCUMENT 'website'; FORMATs: html, json, pickle, web")
     
    10741074    logger = setup_logger(options.verbose, options.color)
    10751075
    10761076    # Process selected options.
    1077     if options.jsmath:
    1078         os.environ['SAGE_DOC_JSMATH'] = "True"
     1077    if (options.mathjax or (os.environ.get('SAGE_DOC_MATHJAX', False))
     1078        or (os.environ.get('SAGE_DOC_JSMATH', False))):
     1079        os.environ['SAGE_DOC_MATHJAX'] = "True"
    10791080
    10801081    if options.check_nested:
    10811082        os.environ['SAGE_CHECK_NESTED'] = 'True'
  • doc/common/conf.py

    diff --git a/doc/common/conf.py b/doc/common/conf.py
    a b  
    2727#, 'sphinx.ext.intersphinx']
    2828
    2929
    30 if 'SAGE_DOC_JSMATH' in os.environ:
    31     extensions.append('sphinx.ext.jsmath')
    32 else:
    33     extensions.append('sphinx.ext.pngmath')
    34 jsmath_path = 'jsmath_sage.js'
    35 
    3630# Add any paths that contain templates here, relative to this directory.
    3731templates_path = [os.path.join(SAGE_DOC, 'common/templates'), 'templates']
    3832
     
    134128# -----------------------
    135129
    136130# HTML theme (e.g., 'default', 'sphinxdoc').  We use a custom Sage
    137 # theme to set a Pygments style, stylesheet, and insert jsMath macros. See
     131# theme to set a Pygments style, stylesheet, and insert MathJax macros. See
    138132# the directory doc/common/themes/sage/ for files comprising the custom Sage
    139133# theme.
    140134html_theme = 'sage'
     
    144138# see the documentation.
    145139html_theme_options = {}
    146140
    147 if 'SAGE_DOC_JSMATH' in os.environ:
    148     from sage.misc.latex_macros import sage_jsmath_macros_easy
    149     html_theme_options['jsmath_macros'] = sage_jsmath_macros_easy
    150 
    151     from sage.misc.package import is_package_installed
    152     html_theme_options['jsmath_image_fonts'] = is_package_installed('jsmath-image-fonts')
    153 
    154141# Add any paths that contain custom themes here, relative to this directory.
    155142html_theme_path = [os.path.join(SAGE_DOC, 'common/themes')]
    156143
     
    179166# so a file named "default.css" will overwrite the builtin "default.css".
    180167html_static_path = [os.path.join(SAGE_DOC, 'common/static'), 'static']
    181168
    182 # If we're using jsMath, we prepend its location to the static path
    183 # array.  We can override / overwrite selected files by putting them
    184 # in the remaining paths.
    185 if 'SAGE_DOC_JSMATH' in os.environ:
     169# The environment variable SAGE_DOC_MATHJAX may be set by the user or
     170# by the file "builder.py".  If it's set, or if SAGE_DOC_JSMATH is set
     171# (for backwards compatibility), use MathJax.
     172if (os.environ.get('SAGE_DOC_MATHJAX', False)
     173    or os.environ.get('SAGE_DOC_JSMATH', False)):
     174
     175    extensions.append('sphinx.ext.mathjax')
     176    mathjax_path = 'MathJax.js?config=TeX-AMS_HTML-full,../mathjax_sage.js'
     177
     178    from sage.misc.latex_macros import sage_mathjax_macros
     179    html_theme_options['mathjax_macros'] = sage_mathjax_macros
     180
    186181    from pkg_resources import Requirement, working_set
    187182    sagenb_path = working_set.find(Requirement.parse('sagenb')).location
    188     jsmath_static = os.path.join(sagenb_path, 'sagenb', 'data', 'jsmath')
    189     html_static_path.insert(0, jsmath_static)
     183    mathjax_relative = os.path.join('sagenb','data','mathjax')
     184
     185    # It would be really nice if sphinx would copy the entire mathjax directory,
     186    # (so we could have a _static/mathjax directory), rather than the contents of the directory
     187
     188    mathjax_static = os.path.join(sagenb_path, mathjax_relative)
     189    html_static_path.append(mathjax_static)
     190    exclude_patterns=['**/'+os.path.join(mathjax_relative, i) for i in ('docs', 'README*', 'test',
     191                                                                        'unpacked', 'LICENSE')]
     192else:
     193     extensions.append('sphinx.ext.pngmath')
     194
    190195
    191196# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
    192197# using the given strftime format.
     
    428433        for i in range(len(lines)):
    429434            docstringlines[i] = lines[i]
    430435
    431 def process_mathtt(app, what, name, obj, options, docstringlines):
    432     r"""
    433     Replace \mathtt{BLAH} with \verb|BLAH| if using jsMath.
    434     See sage.misc.sagedoc.process_mathtt for more information
    435     """
    436     if (len(docstringlines) > 0 and 'SAGE_DOC_JSMATH' in os.environ
    437         and name.find("process_mathtt") == -1):
    438         from sage.misc.sagedoc import process_mathtt as sagedoc_mathtt
    439         s = sagedoc_mathtt("\n".join(docstringlines), True)
    440         lines = s.split("\n")
    441         for i in range(len(lines)):
    442             docstringlines[i] = lines[i]
    443 
    444436def process_inherited(app, what, name, obj, options, docstringlines):
    445437    """
    446438    If we're including inherited members, omit their docstrings.
     
    604596    app.connect('autodoc-process-docstring', process_directives)
    605597    app.connect('autodoc-process-docstring', process_docstring_module_title)
    606598    app.connect('autodoc-process-docstring', process_dollars)
    607     app.connect('autodoc-process-docstring', process_mathtt)
    608599    app.connect('autodoc-process-docstring', process_inherited)
    609600    app.connect('autodoc-skip-member', skip_member)
    610601
  • .js_t

    diff --git a/doc/common/themes/sage/static/jsmath_sage.js_t b/doc/common/themes/sage/static/mathjax_sage.js_t
    rename from doc/common/themes/sage/static/jsmath_sage.js_t
    rename to doc/common/themes/sage/static/mathjax_sage.js_t
    old new  
    1 /**********************************************************************
    2  *
    3  *   Customize the values given below to suit your needs.
    4  *   You can make additional copies of this file with
    5  *   different customizated settings if you need to load
    6  *   jsMath with different parameters.
    7  *
    8  *   Load this page via:
    9  *
    10  *   <SCRIPT SRC="path-to-jsMath/easy/load.js"></SCRIPT>
    11  *
    12  *   (If you are including this file into your page via Server-Side
    13  *   Includes, you should remove line above.)
    14  *
    15  *   You can make copies of this file with different settings
    16  *   if you need to have several different configurations.
    17  *
    18  **********************************************************************/
     1MathJax.Hub.Config({
     2  imageFont: null,
     3  tex2jax: {
     4    inlineMath: [['$','$'],['\\(','\\)']],
     5    processEscapes: true,
     6  },
     7  styles: {
     8    ".MathJax .mo, .MathJax .mi": {
     9      color: "inherit ! important"
     10    }
     11  },
     12  TeX: {
     13    Macros: {
     14     {{ theme_mathjax_macros|join(',\n') }}
     15    }
     16  }
     17});
    1918
    20     if (!window.jsMath) {window.jsMath = {}}
    21 
    22 //  Move the jsMath button 20 pixels from the right edge (apparently
    23 //  in some browsers, it covers up the scroll bar)
    24 jsMath.styles = {
    25     '#jsMath_button' : 'position:fixed; bottom:1px; right:20px; '
    26         + 'background-color:white; border: solid 1px #959595; margin:0px; '
    27         + 'padding: 0px 3px 1px 3px; z-index:102; color:black; '
    28         + 'text-decoration:none; font-size:x-small; width:auto; cursor:hand;'
    29 }
    30 
    31 jsMath.Easy = {
    32     //
    33     //  The URL of the root jsMath directory on your server
    34     //  (it must be in the same domain as the HTML page).
    35     //  It should include "http://yoursite.com/", or should
    36     //  be relative to the root of your server.  It is possible
    37     //  to be a relative URL, but it will be relative to the
    38     //  HTML page loading this file.
    39     //
    40     //  If you leave this blank, jsMath will try to look it up from
    41     //  the URL where it loaded this file, but that may not work.
    42     //
    43     root: "",
    44 
    45     //
    46     //  The default scaling factor for mathematics compared to the
    47     //  surrounding text.
    48     //
    49     scale: 115,
    50 
    51     //
    52     //  1 means use the autoload plug-in to decide if jsMath should be loaded
    53     //  0 means always load jsMath
    54     //
    55     autoload: 1,
    56 
    57     //
    58     //  Setting any of these will cause the tex2math plugin to be used
    59     //  to add the <DIV> and <SPAN> tags that jsMath needs.  See the
    60     //  documentation for the tex2math plugin for more information.
    61     //
    62     processSlashParens: 0,       // process \(...\) in text?
    63     processSlashBrackets: 0,     // process \[...\] in text?
    64     processDoubleDollars: 0,     // process $$...$$ in text?
    65     processSingleDollars: 0,     // process $...$ in text?
    66     processLaTeXenvironments: 0, // process \begin{xxx}...\end{xxx} outside math mode?
    67     fixEscapedDollars: 0,        // convert \$ to $ outside of math mode?
    68     doubleDollarsAreInLine: 0,   // make $$...$$ be in-line math?
    69     allowDisableTag: 0,          // allow ID="tex2math_off" to disable tex2math?
    70     //
    71     //  If you want to use your own custom delimiters for math instead
    72     //  of the usual ones, then uncomment the following four lines and
    73     //  insert your own delimiters within the quotes.  You may want to
    74     //  turn off processing of the dollars and other delimiters above
    75     //  as well, though you can use them in combination with the
    76     //  custom delimiters if you wish.  See the tex2math documentation
    77     //  for more details.
    78     //
    79     //customDelimiters: [
    80     //  '[math]','[/math]',        // to begin and end in-line math
    81     //  '[display]','[/display]'   // to begin and end display math
    82     //],
    83 
    84     //
    85     //  Disallow the use of the @(...) mechanism for including raw HTML
    86     //  in the contents of \hbox{}?  (If used in a content-management system
    87     //  where users are allowed to enter mathematics, setting this to 0
    88     //  would allow them to enter arbitrary HTML code within their
    89     //  math formulas, and that poses a security risk.)
    90     //
    91     safeHBoxes: 1,
    92 
    93     //
    94     //  Show TeX source when mathematics is double-clicked?
    95     //
    96     allowDoubleClicks: 1,
    97 
    98     //
    99     //  Show jsMath font warning messages?  (Disabling this prevents yours
    100     //  users from finding out that they can have a better experience on your
    101     //  site by installing some fonts, so don't disable this).
    102     //
    103     showFontWarnings: 0,
    104 
    105     //
    106     //  Use "Process" or "ProcessBeforeShowing".  See the jsMath
    107     //  author's documentation for the difference between these
    108     //  two routines.
    109     //
    110     method: "Process",
    111 
    112     //
    113     //  List of plug-ins and extensions that you want to be
    114     //  loaded automatically.  E.g.
    115     //      ["plugins/mimeTeX.js","extensions/AMSsymbols.js"]
    116     //
    117     loadFiles: [
    118         "extensions/verb.js",
    119         "extensions/moreArrows.js",
    120         "extensions/AMSmath.js",
    121         "extensions/AMSsymbols.js"
    122     ],
    123 
    124     //
    125     //  List of fonts to load automatically.  E.g.
    126     //      ["cmmib10"]
    127     //
    128     loadFonts: [],
    129 
    130     //
    131     //  List of macros to define.  These are of the form
    132     //      name: value
    133     //  where 'value' is the replacement text for the macro \name.
    134     //  The 'value' can also be [value,n] where 'value' is the replacement
    135     //  text and 'n' is the number of parameters for the macro.
    136     //  Note that backslashes must be doubled in the replacement string.
    137     //  E.g.,
    138     //      {
    139     //        RR: '{\\bf R}',
    140     //        bold: ['{\\bf #1}', 1]
    141     //      }
    142     //
    143     // Sage-specific jsMath macros.
    144     macros: {
    145     {{ theme_jsmath_macros|join(',\n') }}
    146     },
    147 
    148     //
    149     //  Allow jsMath to enter global mode?
    150     //  (Uses frames, so may not always work with complex web sites)
    151     //
    152     allowGlobal: 1,
    153 
    154     //
    155     //  Disable image fonts?  (In case you don't load them on your server.)
    156     //
    157     // If we set this to 1, we do not need to load plugins/noImageFonts.js
    158     {% if theme_jsmath_image_fonts %}
    159     noImageFonts: 0
    160     {% else %}
    161     noImageFonts: 1
    162     {% endif %}
    163 };
    164 
    165 /****************************************************************/
    166 /****************************************************************/
    167 //
    168 //            DO NOT MAKE CHANGES BELOW THIS
    169 //
    170 /****************************************************************/
    171 /****************************************************************/
    172 
    173 jsMath.Easy.find_root = function () {
    174     if (jsMath.Easy.root == "") {
    175         jsMath.Easy.root = document.getElementsByTagName("script");
    176         for (var i = 0; i < jsMath.Easy.root.length; i++) {
    177             if (jsMath.Easy.root[i].src.match(/doctools.js$/)) {
    178                 jsMath.Easy.root = jsMath.Easy.root[i].src.replace(/doctools.js$/, "");
    179                 return;
    180             }
    181         }
    182         jsMath.Easy.root = jsMath.Easy.root[jsMath.Easy.root.length-1].src
    183         if (jsMath.Easy.root.match(/\/easy\/[^\/]*$/)) {
    184             jsMath.Easy.root = jsMath.Easy.root.replace(/\/easy\/[^\/]*$/,"");
    185         } else {
    186             jsMath.Easy.root = jsMath.Easy.root.replace(/\/(jsMath\/(easy\/)?)?[^\/]*$/,"/jsMath");
    187         }
    188     }
    189 };
    190 
    191 jsMath.Easy.find_root();
    192 
    193 jsMath.Easy.root = jsMath.Easy.root.replace(/\/$/,""); // trim trailing "/" if any
    194 
    195 document.write('<SCRIPT SRC="'+jsMath.Easy.root+'/jsMath-easy-load.js"><'+'/SCRIPT>');
     19// This path is a little funny because we have to load our local
     20// config file as '../mathjax_sage' in the theme conf.py
     21MathJax.Ajax.loadComplete("[MathJax]/config/../mathjax_sage.js")
  • doc/common/themes/sage/theme.conf

    diff --git a/doc/common/themes/sage/theme.conf b/doc/common/themes/sage/theme.conf
    a b  
    66[options]
    77# Custom Sage theme options
    88
    9 # jsMath settings filled in by conf.py
    10 jsmath_macros =
    11 jsmath_image_fonts =
     9# MathJax settings filled in by conf.py
     10mathjax_macros =
    1211
    1312# Sphinx default theme options
    1413
  • doc/de/tutorial/latex.rst

    diff --git a/doc/de/tutorial/latex.rst b/doc/de/tutorial/latex.rst
    a b  
    2929       mit dem ``latex()``-Befehl  aus und fügen Sie es in Ihr Dokument ein.
    3030
    3131    #. Die Notebook Schnittstelle ist konfiguriert
    32        `jsMath <http://www.math.union.edu/~dpvc/jsMath/>`_
     32       `MathJax <http://www.mathjax.org>`_
    3333       zu nutzen um mathematische Ausdrücke im Browser darzustellen.
    34        jsMath ist eine Kollektion aus JavaScript-Routinen und
     34       MathJax ist eine Kollektion aus JavaScript-Routinen und
    3535       zugehörigen Schriftarten. Es ist also nichts zusätzlich
    3636       einzustellen um mathematische Ausdrücke in Ihrem Browser
    3737       anzuzeigen, wenn Sie das Sage-Notebook nutzen.
    3838       
    39        jsMath wurde entwickelt um einen großen, aber nicht vollständigen
     39       MathJax wurde entwickelt um einen großen, aber nicht vollständigen
    4040       Teil von TeX darstellen zu können. Es gibt keine Unterstützung
    4141       für Dinge, wie komplizierte Tabellen, Kapiteleinteilung oder
    4242       Dokument Management, da es für genaues Darstellen von TeX
    4343       Ausdrücken konzipiert wurde. Die nahtlose Darstellung von
    4444       mathematischen Ausdrücken im Sage Notebook wird durch
    45        Konvertierung der ``latex()``-Darstellung in jsMath
     45       Konvertierung der ``latex()``-Darstellung in MathJax
    4646       gewährleistet.
    4747       
    48        Da jsMath seine eigenen skalierbaren Schriftarten nutzt, ist es
     48       Da MathJax seine eigenen skalierbaren Schriftarten nutzt, ist es
    4949       anderen Methoden überlegen, die auf Konvertierung in kleine
    5050       Bilder beruhen.
    5151       
    52        jsMath wird möglicherweise von MathJAX abgelöst werden, einer
    53        ähnlichen Technik, die vom gleichen Author stammt und eine
    54        breite Unterstützung von Technikern und professionellen 
    55        Vereinen hat.
    56        
    5752    #. Sollte in der Sage Kommandozeile oder im Notebook mehr
    58        LaTeX-Code vorkommen als jsMath verarbeiten kann, kann eine
     53       LaTeX-Code vorkommen als MathJax verarbeiten kann, kann eine
    5954       systemweite Installation von LaTeX aushelfen. Sage beinhaltet
    6055       fast alles, das Sie brauchen um Sage weiter zu entwickeln und
    6156       zu nutzen. Eine Ausnahme hierzu ist TeX selbst. In diesen
     
    7166    sage: latex(integrate(z^4, z))
    7267    \frac{1}{5} \, z^{5}
    7368    sage: latex('a string')
    74     \verb|a|\phantom{x}\verb|string|
     69    \verb|a|\phantom{\verb!x!}\verb|string|
    7570    sage: latex(QQ)
    7671    \Bold{Q}
    7772    sage: latex(matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]]))
     
    8075    -1 & -1 & -1
    8176    \end{array}\right)
    8277
    83 Grundlegende jsMath Funktionen gibt es im Notebook weitgehend automatisch,
    84 aber wir können es teilweise mit Hilfe der ``JSMath`` Klasse demonstrieren.
     78Grundlegende MathJax Funktionen gibt es im Notebook weitgehend automatisch,
     79aber wir können es teilweise mit Hilfe der ``MathJax`` Klasse demonstrieren.
    8580Die ``eval`` Funktion dieser Klasse konvertiert ein Sage-Objekt in
    8681seine LaTeX-Darstellung und dann in HTML mit der CSS ``math`` Klasse,
    87 die dann jsMath verwendet. ::
     82die dann MathJax verwendet. ::
    8883
    89     sage: from sage.misc.latex import JSMath
    90     sage: js = JSMath()
     84    sage: from sage.misc.latex import MathJax
     85    sage: mj = MathJax()
    9186    sage: var('z')
    9287    z
    93     sage: js(z^12)
    94     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}z^{12}</div></html>
    95     sage: js(QQ)
    96     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}</div></html>
    97     sage: js(ZZ[x])
    98     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}[x]</div></html>
    99     sage: js(integrate(z^4, z))
    100     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{5} \, z^{5}</div></html>
    101 
     88    sage: mj(z^12)
     89    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}z^{12}</script></html>
     90    sage: mj(QQ)
     91    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}</script></html>
     92    sage: mj(ZZ[x])
     93    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}[x]</script></html>
     94    sage: mj(integrate(z^4, z))
     95    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{5} \, z^{5}</script></html>
    10296   
    10397Grundlegende Nutzung
    10498====================
     
    120114:ref:`sec-custom-processing`).
    121115
    122116Im Notebook schafft der ``view(foo)`` Befehl die nötige Kombination
    123 von HTML und CSS sodass jsMath die LaTeX Darstellung im Arbeitsblatt
     117von HTML und CSS sodass MathJax die LaTeX Darstellung im Arbeitsblatt
    124118anzeigt. Für den Anwender erstellt er einfach eine schön formatierte
    125119Ausgabe, die sich von der normalen ASCII Ausgabe aus Sage
    126120unterscheidet. Nicht jedes mathematische Objekt in Sage hat eine
    127 LaTeX-Darstellung, die die eingeschränkten Möglichkeiten von jsMath
    128 unterstützt. In diesen Fällen kann die jsMath Darstellung umgangen
     121LaTeX-Darstellung, die die eingeschränkten Möglichkeiten von MathJax
     122unterstützt. In diesen Fällen kann die MathJax Darstellung umgangen
    129123werden, und stattdessen die systemweite TeX-Installation aufgerufen
    130124werden. Dessen Ausgabe kann dann als Bild im Arbeitsblatt angezeigt
    131125werden. Die Einstellungen und Auswirkungen dieses Prozesses wird im
    132126Kapitel :ref:`sec-custom-generation` dargestellt.
    133127
    134128Der interne ``pretty_print()`` Befehl zeigt die Konvertierung von Sage
    135 Objekten in HTML Code der jsMath nutzt im Notebook.  ::
     129Objekten in HTML Code der MathJax nutzt im Notebook.  ::
    136130
    137131    sage: from sage.misc.latex import pretty_print
    138132    sage: pretty_print(x^12)
    139     <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}x^{12}</span></html>
     133    <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}x^{12}</script></html>
    140134    sage: pretty_print(integrate(sin(x), x))
    141     <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}-\cos\left(x\right)</span></html>
     135    <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}-\cos\left(x\right)</script></html>
    142136
    143137Das Notebook hat zwei weitere Möglichkeiten TeX zu nutzen. Die erste
    144138ist der "Typeset"-Knopf über der ersten Zelle eines Arbeitsblatts,
    145139rechts von den vier Drop-Down-Boxen. Ist er ausgewählt werden die
    146 Ausgaben aller folgenden Berechnungen von jsMath
     140Ausgaben aller folgenden Berechnungen von MathJax
    147141interpretiert. Beachten Sie, dass dieser Befehl nicht rückwirkend ist
    148142-- alle vorher berechneten Zellen werden nicht neu berechnet. Im
    149143Grunde ist der "Typeset"-Knopf gleichzusetzen mit dem Aufruf des
     
    157151Text mit einem WYSIWYG-Editor. Es ist also möglich den so formatierten
    158152Text als Kommentar in einem  Arbeitsblatt unterzubringen. Text den Sie
    159153hier zwischen ``$...$`` oder ``$$...$$`` eingeben wird ebenfalls von
    160 jsMath in einer "inline" bzw. "display math" Umgebung gesetzt. 
     154MathJax in einer "inline" bzw. "display math" Umgebung gesetzt. 
    161155
    162156.. _sec-custom-generation:
    163157
     
    210204
    211205    sage: latex(QQ)
    212206    \Bold{Q}
    213     sage: from sage.misc.latex import JSMath
    214     sage: js=JSMath()
    215     sage: js(QQ)
    216     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}</div></html>
     207    sage: from sage.misc.latex import MathJax
     208    sage: mj=MathJax()
     209    sage: mj(QQ)
     210    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}</script></html>
    217211    sage: latex.blackboard_bold(True)
    218     sage: js(QQ)
    219     <html><div class="math">\newcommand{\Bold}[1]{\mathbb{#1}}\Bold{Q}</div></html>
     212    sage: mj(QQ)
     213    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbb{#1}}\Bold{Q}</script></html>
    220214    sage: latex.blackboard_bold(False)
    221215
    222216Dank der Erweiterbarkeit von TeX können Sie selbst Makros und Pakete
    223217einbinden. Individuelle Makros können hinzugefügt werden, die dann von
    224 jsMath als TeX-Schnipsel  interpretiert werden. ::
     218MathJax als TeX-Schnipsel  interpretiert werden. ::
    225219
    226220    sage: latex.extra_macros()
    227221    ''
     
    232226    (x, y)
    233227    sage: latex(x+y)
    234228    x + y
    235     sage: from sage.misc.latex import JSMath
    236     sage: js=JSMath()
    237     sage: js(x+y)
    238     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\newcommand{\foo}{bar}x + y</div></html>
     229    sage: from sage.misc.latex import MathJax
     230    sage: mj=MathJax()
     231    sage: mj(x+y)
     232    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\newcommand{\foo}{bar}x + y</script></html>   
    239233
    240234Zusätzliche Makros, die so hinzugefügt wurden, werden auch vom
    241 systemweiten TeX genutzt, wenn jsMath an seine Grenzen gestoßen ist.
     235systemweiten TeX genutzt, wenn MathJax an seine Grenzen gestoßen ist.
    242236Der Befehl ``latex_extra_preamble`` kann genutzt werden um eine
    243237Präambel eines kompletten LaTeX Dokuments zu erzeugen, das folgende
    244238Beispiel zeigt wie. Beachten Sie wiederrum die doppelten Backslashes
     
    304298Es ist möglich zu entscheiden welche Variante von TeX für einen
    305299systemweiten Aufruf genutzt werden soll, und somit auch wie die
    306300Ausgabe aussehen soll. Ebenso ist es möglich zu beeinflussen, ob das
    307 Notebook jsMath oder die systemweite LaTeX Installation nutzt.
     301Notebook MathJax oder die systemweite LaTeX Installation nutzt.
    308302
    309303Der Befehl ``latex.engine()`` entscheidet, ob die systemweiten
    310304Anwendungen ``latex``, ``pdflatex`` oder ``xelatex`` genutzt werden
     
    317311wird. (acrobat, okular, evince, etc.).
    318312
    319313Im Notebook kann es nötig sein, dem System die Entscheidung
    320 abzunehmen, ob jsMath für einige TeX-Schnipsel, oder das systemweite
     314abzunehmen, ob MathJax für einige TeX-Schnipsel, oder das systemweite
    321315LaTeX für kompliziertere Ausdrücke genutzt werden soll. Es gibt eine
    322316Liste von Befehlen, die wenn einer von ihnen in einem Stück LaTeX-Code
    323317erkannt wird, die Ausgabe von LaTeX (oder welcher Prozessor auch immer
    324 durch ``latex.engine()`` gesetzt ist) statt von jsMath erstellen
     318durch ``latex.engine()`` gesetzt ist) statt von MathJax erstellen
    325319lässt. Diese Liste wird verwaltet durch die Befehle
    326 ``latex.add_to_jsmath_avoid_list`` und
    327 ``latex.jsmath_avoid_list``. ::
     320``latex.add_to_mathjax_avoid_list`` und
     321``latex.mathjax_avoid_list``. ::
    328322
    329     sage: latex.jsmath_avoid_list([])
    330     sage: latex.jsmath_avoid_list()
     323    sage: latex.mathjax_avoid_list([])
     324    sage: latex.mathjax_avoid_list()
    331325    []
    332     sage: latex.jsmath_avoid_list(['foo', 'bar'])
    333     sage: latex.jsmath_avoid_list()
     326    sage: latex.mathjax_avoid_list(['foo', 'bar'])
     327    sage: latex.mathjax_avoid_list()
    334328    ['foo', 'bar']
    335     sage: latex.add_to_jsmath_avoid_list('tikzpicture')
    336     sage: latex.jsmath_avoid_list()
     329    sage: latex.add_to_mathjax_avoid_list('tikzpicture')
     330    sage: latex.mathjax_avoid_list()
    337331    ['foo', 'bar', 'tikzpicture']
    338     sage: latex.jsmath_avoid_list([])
    339     sage: latex.jsmath_avoid_list()
     332    sage: latex.mathjax_avoid_list([])
     333    sage: latex.mathjax_avoid_list()
    340334    []
    341335
    342336Nehmen wir an ein LaTeX-Ausdruck wurde im Notebook durch ``view()``
    343337oder während aktiviertem "Typeset" Knopf erzeugt. Und dann wird
    344338festgestellt, dass er die externe LaTeX-Installation benötigt, weil
    345 er in der ``jsmath_avoid_list`` steht. Der Ausdruck wird nun vom
     339er in der ``mathjax_avoid_list`` steht. Der Ausdruck wird nun vom
    346340ausgewählten (durch ``latex.engine()``) Prozessor erzeugt, und statt
    347341der Anzeige in einem externen Programm (was in der Kommandozeile
    348342passieren  würde) wird Sage versuchen das Ergebnis in einem einzigen,
     
    398392    'latex.add_to_preamble("\\usepackage[matrix,arrow,curve,cmtip]{xy}")',
    399393    and try viewing again -- it should work in the command line but not
    400394    from the notebook.  In the notebook, run
    401     'latex.add_to_jsmath_avoid_list("xymatrix")' and try again -- you
     395    'latex.add_to_mathjax_avoid_list("xymatrix")' and try again -- you
    402396    should get a picture (a part of the diagram arising from a filtered
    403397    chain complex).
    404398
     
    430424erfolgreich eine .pdf Datei mit einem  Bild vom kompletten `K_4`
    431425Graphen erzeugen.
    432426
    433 Um das Gleiche im Notebook zu erstellen, müssen Sie jsMath
     427Um das Gleiche im Notebook zu erstellen, müssen Sie MathJax
    434428für die Verarbeitung von LaTeX-Code ausschalten, indem Sie
    435 die "jsmath avoid list" benutzen. Graphen werden in einer
     429die "mathjax avoid list" benutzen. Graphen werden in einer
    436430``tikzpicture`` Umgebung eingebunden, das ist also eine gute Wahl
    437431für die Zeichenkette für die Ausschlussliste. Jetzt sollte
    438432``view(graphs.CompleteGraph(4))`` in einem Arbeitsblatt
     
    447441    sage: latex.extra_preamble() # random - depends on system's TeX installation
    448442    '\\usepackage{tikz}\n\\usepackage{tkz-graph}\n\\usepackage{tkz-berge}\n'
    449443    sage: latex.engine('pdflatex')
    450     sage: latex.add_to_jsmath_avoid_list('tikzpicture')
    451     sage: latex.jsmath_avoid_list()
     444    sage: latex.add_to_mathjax_avoid_list('tikzpicture')
     445    sage: latex.mathjax_avoid_list()
    452446    ['tikzpicture']
    453447
    454448Beachten Sie, dass es eine Vielzahl von Optionen gibt, die die
     
    494488
    495489tex2sws beginnt mit einem LaTeX-Dokument, aber definiert einige zusätzliche
    496490Umgebungen für Sage Code. Wenn es richtig genutzt wird, ist das Ergebnis ein
    497 Sage Arbeitsblatt mit korrekt von jsMath formatiertem Inhalt und dem dazugehörigen
     491Sage Arbeitsblatt mit korrekt von MathJax formatiertem Inhalt und dem dazugehörigen
    498492Sage Code in den Eingabezellen. Ein Lehrbuch oder Artikel kann also mit Sage Code Blöcken
    499493in LaTeX gesetzt werden und es kann "live" das ganze Dokument in ein Sage Arbeitsblatt überführt werden;
    500494unter Beibehaltung der Sage Code Blöcke und mit schön formatiertem mathematischen Text.
  • doc/en/introspect/conf.py

    diff --git a/doc/en/introspect/conf.py b/doc/en/introspect/conf.py
    a b  
    66sys.path.append(os.environ['SAGE_DOC'])
    77from common.conf import *
    88
    9 extensions = ['sphinx.ext.autodoc', 'sphinx.ext.jsmath', 'sphinx.ext.todo',
     9extensions = ['sphinx.ext.autodoc', 'sphinx.ext.mathjax', 'sphinx.ext.todo',
    1010              'sphinx.ext.extlinks']
    1111
    1212templates_path = ['templates']
  • doc/en/thematic_tutorials/conf.py

    diff --git a/doc/en/thematic_tutorials/conf.py b/doc/en/thematic_tutorials/conf.py
    a b  
    2828# Output file base name for HTML help builder.
    2929htmlhelp_basename = "thematic_tutorials"
    3030
    31 # mathfrak isn't defined in jsMath, so using it gives errors.  The
    32 # following line turns it into bold face only when using jsMath, thus
    33 # avoiding the errors, while keeping the nice mathfrak fonts when not
    34 # using jsMath.
    35 try:
    36     html_theme_options['jsmath_macros'].append("mathfrak : ['\\\\mathbf{#1}', 1]")
    37 except KeyError:
    38     html_theme_options['jsmath_macros'] = ["mathfrak : ['\\\\mathbf{#1}', 1]"]
    39 
    4031# Grouping the document tree into LaTeX files. List of tuples
    4132# (source start file, target name, title, author,
    4233# document class [howto/manual]).
  • doc/en/tutorial/latex.rst

    diff --git a/doc/en/tutorial/latex.rst b/doc/en/tutorial/latex.rst
    a b  
    3131       of the object and cut/paste it into your document.
    3232
    3333    #. The notebook interface is configured to use
    34        `jsMath <http://www.math.union.edu/~dpvc/jsMath/>`_
     34       `MathJax <http://www.mathjax.org>`_
    3535       to render mathematics
    36        cleanly in a web browser.  jsMath is a collection of JavaScript routines
    37        and associated fonts.  Typically, these fonts live on a server and are
    38        sent to a browser along with the web page that displays them.  In the
    39        case of Sage, the notebook is always connected to a server used to
    40        execute the Sage commands, and this server also provides the necessary
    41        jsMath fonts.  So there is nothing extra to set up to have typeset
    42        mathematics in your web browser when you use the Sage notebook.
    43 
    44        jsMath is implemented to be able to render a large, but
    45        not totally complete, subset of TeX.  It has no support for
     36       cleanly in a web browser.  MathJax is an open source JavaScript
     37       display engine for mathematics that works in all modern
     38       browsers.  It is able to render a large, but not totally
     39       complete, subset of TeX.  It has no support for
    4640       things like complicated tables, sectioning or document
    4741       management, as it is oriented towards accurately rendering
    4842       "snippets" of TeX. Seemingly automatic rendering of math in the
    4943       notebook is provided by converting the ``latex()``
    5044       representation of an object (as described above) into a form of
    51        HTML palatable to jsMath.
     45       HTML palatable to MathJax.
    5246
    53        Since jsMath uses its own scalable fonts, it is superior to other methods that
     47       Since MathJax uses its own scalable fonts, it is superior to other methods that
    5448       rely on converting equations, or other snippets of TeX, into static inline images.
    5549
    56        jsMath is likely to be superseded by MathJAX, a similar technology
    57        from the same author, which has broad support from technical publishers
    58        and professional societies.
    59 
    6050    #. At the Sage command-line, or in the notebook when LaTeX code is
    61        more involved than jsMath can handle, a system-wide installation of
     51       more involved than MathJax can handle, a system-wide installation of
    6252       LaTeX can be employed.  Sage includes almost everything you need to
    6353       build and use Sage, but a significant exception is TeX itself.  So in these
    6454       situations you need to have TeX installed, along with some associated
     
    7363    sage: latex(integrate(z^4, z))
    7464    \frac{1}{5} \, z^{5}
    7565    sage: latex('a string')
    76     \verb|a|\phantom{x}\verb|string|
     66    \verb|a|\phantom{\verb!x!}\verb|string|
    7767    sage: latex(QQ)
    7868    \Bold{Q}
    7969    sage: latex(matrix(QQ, 2, 3, [[2,4,6],[-1,-1,-1]]))
     
    8272    -1 & -1 & -1
    8373    \end{array}\right)
    8474
    85 Basic jsMath functionality is largely automatic in the notebook, but
    86 we can partially demonstrate this support with the ``JSMath`` class,
     75Basic MathJax functionality is largely automatic in the notebook, but
     76we can partially demonstrate this support with the ``MathJax`` class,
    8777The ``eval`` function of this class converts a Sage object to its
    8878LaTeX representation and then wraps it in HTML that invokes the CSS
    89 "math" class, which then employs jsMath.  ::
     79"math" class, which then employs MathJax.  ::
    9080
    91     sage: from sage.misc.latex import JSMath
    92     sage: js = JSMath()
     81    sage: from sage.misc.latex import MathJax
     82    sage: mj = MathJax()
    9383    sage: var('z')
    9484    z
    95     sage: js(z^12)
    96     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}z^{12}</div></html>
    97     sage: js(QQ)
    98     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}</div></html>
    99     sage: js(ZZ[x])
    100     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}[x]</div></html>
    101     sage: js(integrate(z^4, z))
    102     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{5} \, z^{5}</div></html>
     85    sage: mj(z^12)
     86    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}z^{12}</script></html>
     87    sage: mj(QQ)
     88    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}</script></html>
     89    sage: mj(ZZ[x])
     90    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}[x]</script></html>
     91    sage: mj(integrate(z^4, z))
     92    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1}{5} \, z^{5}</script></html>
    10393
    10494Basic Use
    10595=========
     
    121111viewer, can be customized (see :ref:`sec-custom-processing`).
    122112
    123113In the notebook, the ``view(foo)`` command creates the
    124 appropriate combination of HTML and CSS so that jsMath will
     114appropriate combination of HTML and CSS so that MathJax will
    125115render the LaTeX representation properly in the worksheet.  To the
    126116user, it simply creates a nicely formatted version of the output,
    127117distinct from the default ASCII output of Sage.  Not every
    128118mathematical object in Sage has a LaTeX representation amenable to
    129 the limited capabilities of jsMath.  In these cases, the jsMath
     119the limited capabilities of MathJax.  In these cases, the MathJax
    130120interpretation can be bypassed, the system-wide TeX called
    131121instead, and the subsequent output converted to a graphic image
    132122for display in the worksheet.  Affecting and controlling this
     
    134124:ref:`sec-custom-generation`.
    135125
    136126The internal ``pretty_print()`` command illustrates the
    137 conversion of Sage objects to HTML code that employs jsMath in
     127conversion of Sage objects to HTML code that employs MathJax in
    138128the notebook.  ::
    139129
    140130    sage: from sage.misc.latex import pretty_print
    141131    sage: pretty_print(x^12)
    142     <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}x^{12}</span></html>
     132    <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}x^{12}</script></html>
    143133    sage: pretty_print(integrate(sin(x), x))
    144     <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}-\cos\left(x\right)</span></html>
     134    <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}-\cos\left(x\right)</script></html>
    145135
    146136The notebook has two other features for employing TeX.
    147137The first is the "Typeset" button just above the first cell of a
    148138worksheet, to the right of the four drop-down boxes.  When
    149139checked, any subsequent evaluations of cells will result in
    150 output interpreted by jsMath, hence of a typeset quality.  Note
     140output interpreted by MathJax, hence of a typeset quality.  Note
    151141that this effect is not retroactive -- previously evaluated cells
    152142need to be re-evaluated.  Essentially, checking the "Typeset"
    153143button is identical to wrapping the output of each cell in the
     
    161151HTML and CSS command for styled text.  So it is possible to add
    162152formatted text as commentary within a worksheet.  However, text
    163153between pairs of dollar signs, or pairs of double dollar signs is
    164 interpreted by jsMath as inline or display math (respectively).
     154interpreted by MathJax as inline or display math (respectively).
    165155
    166156.. _sec-custom-generation:
    167157
     
    204194
    205195The way common rings and fields (integers, rational, reals, etc.)
    206196are typeset can be controlled by the ``latex.blackboard_bold``
    207 method.  These sets are by default typset in bold, but may
     197method.  These sets are by default typeset in bold, but may
    208198optionally be written in a double-struck fashion as sometimes
    209199done in written work.  This is accomplished by redefining the
    210200``\Bold{}`` macro which is built-in to Sage. ::
    211201
    212202    sage: latex(QQ)
    213203    \Bold{Q}
    214     sage: from sage.misc.latex import JSMath
    215     sage: js=JSMath()
    216     sage: js(QQ)
    217     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}</div></html>
     204    sage: from sage.misc.latex import MathJax
     205    sage: mj=MathJax()
     206    sage: mj(QQ)
     207    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Q}</script></html>
    218208    sage: latex.blackboard_bold(True)
    219     sage: js(QQ)
    220     <html><div class="math">\newcommand{\Bold}[1]{\mathbb{#1}}\Bold{Q}</div></html>
     209    sage: mj(QQ)
     210    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbb{#1}}\Bold{Q}</script></html>
    221211    sage: latex.blackboard_bold(False)
    222212
    223213It is possible to take advantage of the extensible nature of
    224214tex by adding in new macros and new packages.  First,
    225215individual macros can be added so that they are used when
    226 jsMath interprets a snippet of TeX in the notebook.  ::
     216MathJax interprets a snippet of TeX in the notebook.  ::
    227217
    228218    sage: latex.extra_macros()
    229219    ''
     
    234224    (x, y)
    235225    sage: latex(x+y)
    236226    x + y
    237     sage: from sage.misc.latex import JSMath
    238     sage: js=JSMath()
    239     sage: js(x+y)
    240     <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\newcommand{\foo}{bar}x + y</div></html>
     227    sage: from sage.misc.latex import MathJax
     228    sage: mj=MathJax()
     229    sage: mj(x+y)
     230    <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\newcommand{\foo}{bar}x + y</script></html>   
    241231
    242232Additional macros added this way will also be used in the event
    243233that the system-wide version of TeX is called on
    244 something larger than jsMath can handle.  The command
     234something larger than MathJax can handle.  The command
    245235``latex_extra_preamble`` is used to build the preamble of a
    246236complete LaTeX document, so the following illustrates
    247237how this is accomplished. As usual note the need for the
     
    312302It is also possible to control which variant of TeX is
    313303used for system-wide invocations, thus also influencing the
    314304nature of the output.  Similarly, it is also possible to control
    315 when the notebook will use jsMath (simple TeX snippets)
     305when the notebook will use MathJax (simple TeX snippets)
    316306or the system-wide TeX installation (more complicated
    317307LaTeX expressions).
    318308
     
    328318okular, evince, etc.).
    329319
    330320In the notebook, it is necessary to intervene in the decision as
    331 to whether jsMath will interpret a snippet of TeX, or
     321to whether MathJax will interpret a snippet of TeX, or
    332322if the LaTeX is complicated enough that the system-wide
    333323installation of TeX should do the work instead.  The
    334324device is a list of strings, which if any one is discovered in a
    335325piece of LaTeX code signal the notebook to bypass
    336 jsMath and invoke latex (or whichever executable is set by the
     326MathJax and invoke latex (or whichever executable is set by the
    337327``latex.engine()`` command).  This list is managed by the
    338 ``latex.add_to_jsmath_avoid_list`` and
    339 ``latex.jsmath_avoid_list`` commands. ::
     328``latex.add_to_mathjax_avoid_list`` and
     329``latex.mathjax_avoid_list`` commands. ::
    340330
    341     sage: latex.jsmath_avoid_list([])
    342     sage: latex.jsmath_avoid_list()
     331    sage: latex.mathjax_avoid_list([])
     332    sage: latex.mathjax_avoid_list()
    343333    []
    344     sage: latex.jsmath_avoid_list(['foo', 'bar'])
    345     sage: latex.jsmath_avoid_list()
     334    sage: latex.mathjax_avoid_list(['foo', 'bar'])
     335    sage: latex.mathjax_avoid_list()
    346336    ['foo', 'bar']
    347     sage: latex.add_to_jsmath_avoid_list('tikzpicture')
    348     sage: latex.jsmath_avoid_list()
     337    sage: latex.add_to_mathjax_avoid_list('tikzpicture')
     338    sage: latex.mathjax_avoid_list()
    349339    ['foo', 'bar', 'tikzpicture']
    350     sage: latex.jsmath_avoid_list([])
    351     sage: latex.jsmath_avoid_list()
     340    sage: latex.mathjax_avoid_list([])
     341    sage: latex.mathjax_avoid_list()
    352342    []
    353343
    354344Suppose a LaTeX expression is produced in the notebook
    355345with ``view()`` or while the "Typeset" button is checked, and
    356346then recognized as requiring the external LaTeX
    357 installation through the "jsmath avoid list."  Then the selected
     347installation through the "mathjax avoid list."  Then the selected
    358348executable (as specified by ``latex.engine()``) will process the
    359349LaTeX.  However, instead of then spawning an external
    360350viewer (which is the command-line behavior), Sage will attempt to
     
    410400    'latex.add_to_preamble("\\usepackage[matrix,arrow,curve,cmtip]{xy}")',
    411401    and try viewing again -- it should work in the command line but not
    412402    from the notebook.  In the notebook, run
    413     'latex.add_to_jsmath_avoid_list("xymatrix")' and try again -- you
     403    'latex.add_to_mathjax_avoid_list("xymatrix")' and try again -- you
    414404    should get a picture (a part of the diagram arising from a filtered
    415405    chain complex).
    416406
     
    443433with an appropriate image of the complete graph `K_4`.
    444434
    445435For a similar experience in the notebook, it is necessary
    446 to disable jsMath processing of the LaTeX code for the graph
    447 by using the "jsmath avoid list."  Graphs are included with a
     436to disable MathJax processing of the LaTeX code for the graph
     437by using the "mathjax avoid list."  Graphs are included with a
    448438``tikzpicture`` environment, so this is a good choice for
    449439a string to include in the avoidance list.  Now,
    450440``view(graphs.CompleteGraph(4))`` in a worksheet
     
    459449    sage: latex.extra_preamble() # random - depends on system's TeX installation
    460450    '\\usepackage{tikz}\n\\usepackage{tkz-graph}\n\\usepackage{tkz-berge}\n'
    461451    sage: latex.engine('pdflatex')
    462     sage: latex.add_to_jsmath_avoid_list('tikzpicture')
    463     sage: latex.jsmath_avoid_list()
     452    sage: latex.add_to_mathjax_avoid_list('tikzpicture')
     453    sage: latex.mathjax_avoid_list()
    464454    ['tikzpicture']
    465455
    466456At this point, a command like ``view(graphs.CompleteGraph(4))``
     
    516506tex2sws begins with a LaTeX document, but defines extra
    517507environments for the placement of Sage code.  When processed with
    518508the right tools, the result is a Sage worksheet, with content
    519 properly formatted for jsMath and the Sage code incorporated as
     509properly formatted for MathJax and the Sage code incorporated as
    520510input cells.  So a textbook or article can be authored in
    521511LaTeX, blocks of Sage code included, and the whole
    522512document can be transformed into a Sage worksheet where the
  • sage/all_notebook.py

    diff --git a/sage/all_notebook.py b/sage/all_notebook.py
    a b  
    88
    99sage_mode = 'notebook'
    1010
    11 from sage.misc.latex import Latex, pretty_print_default, JSMath
     11from sage.misc.latex import Latex, pretty_print_default, MathJax
    1212latex = Latex(density=130)
    1313latex_debug = Latex(debug=True, density=130)
    1414slide = Latex(slide=True, density=256)
    1515slide_debug = Latex(slide=True, debug=True, density=256)
    1616pdflatex = Latex(density=130, pdflatex=True)
    1717pdflatex_debug = Latex(density=130, pdflatex=True, debug=True)
    18 # we need a global instance of this in order to get %jsmath to work...
    19 jsmath = JSMath()
    2018
    2119from sage.misc.python import python
    2220
  • sage/graphs/generic_graph.py

    diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
    a b  
    335335        here to ``None``.  Some options are added to the global
    336336        :data:`sage.misc.latex.latex` instance which will insure
    337337        that if `\mbox{\rm\LaTeX}` is used to render the graph,
    338         then the right packages are loaded and jsMath reacts
     338        then the right packages are loaded and MathJax reacts
    339339        properly.
    340340
    341341        Most other initialization is done in the directed
  • sage/graphs/graph_latex.py

    diff --git a/sage/graphs/graph_latex.py b/sage/graphs/graph_latex.py
    a b  
    4848
    4949Customizing the output is accomplished in several ways.  Suppose ``g`` is a graph, then ``g.set_latex_options()`` can be used to efficiently set or modify various options.  Setting individual options, or querying options, can be accomplished by first using a command like ``opts = g.latex_options()`` to obtain a :class:`sage.graphs.graph_latex.GraphLatex` object which has several methods to set and retrieve options.
    5050
    51 Here is a minimal session demonstrating how to use these features. The following setup should work in the notebook or at the command-line, though the call to :meth:`~sage.misc.latex.Latex.jsmath_avoid_list` is only needed in the notebook. ::
     51Here is a minimal session demonstrating how to use these features. The following setup should work in the notebook or at the command-line, though the call to :meth:`~sage.misc.latex.Latex.mathjax_avoid_list` is only needed in the notebook. ::
     52
    5253
    5354    sage: from sage.graphs.graph_latex import setup_latex_preamble
    5455    sage: setup_latex_preamble()
     
    5859    \usepackage{tkz-berge}
    5960    \usetikzlibrary{arrows,shapes}
    6061    sage: latex.engine('pdflatex')
    61     sage: latex.jsmath_avoid_list('tikzpicture')
     62    sage: latex.mathjax_avoid_list('tikzpicture')
    6263    sage: H=graphs.HeawoodGraph()
    6364    sage: H.set_latex_options(
    6465    ...   graphic_size=(5,5),
  • sage/matrix/matrix0.pyx

    diff --git a/sage/matrix/matrix0.pyx b/sage/matrix/matrix0.pyx
    a b  
    19181918            \hline\hline
    19191919            0 & 0 & 0 & 0
    19201920            \end{array}\right)
    1921 
    1922         Note that size-zero subdivisions are ignored in the notebook::
    1923            
    1924             sage: sage.server.support.EMBEDDED_MODE = True
    1925             sage: latex(B)
    1926             \left(\begin{array}{rr}
    1927             \left(\begin{array}{rrr}
    1928             0 & 0 & 0 \\
    1929             0 & 0 & 0
    1930             \end{array}\right) & \left(\begin{array}{r}
    1931             0 \\
    1932             0
    1933             \end{array}\right) \\
    1934             \\
    1935             \left(\begin{array}{rrr}
    1936             0 & 0 & 0
    1937             \end{array}\right) & \left(\begin{array}{r}
    1938             0
    1939             \end{array}\right)
    1940             \end{array}\right)
    1941             sage: sage.server.support.EMBEDDED_MODE = False
    19421921        """
    19431922        latex = sage.misc.latex.latex
    19441923        matrix_delimiters = latex.matrix_delimiters()
     
    19531932       
    19541933        row_divs, col_divs = self.subdivisions()
    19551934       
    1956         from sage.server.support import EMBEDDED_MODE
    1957 
    1958         # jsmath doesn't know the command \hline, so have to do things
    1959         # differently (and not as attractively) in embedded mode:
    1960         # construct an array with a subarray for each block.
    1961         if len(row_divs) + len(col_divs) > 0 and EMBEDDED_MODE:
    1962             for r in range(len(row_divs)+1):
    1963                 s = ""
    1964                 for c in range(len(col_divs)+1):
    1965                     if c == len(col_divs):
    1966                         sep=""
    1967                     else:
    1968                         sep=" & "
    1969                     sub = self.subdivision(r,c)
    1970                     if sub.nrows() > 0 and sub.ncols() > 0:
    1971                         entry = latex(self.subdivision(r,c))
    1972                         s = s + entry + sep
    1973                 rows.append(s)
    1974                
    1975             # Put brackets around in a single string
    1976             tmp = []
    1977             for row in rows:
    1978                 tmp.append(str(row))
    1979 
    1980             s = " \\\\\n".join(tmp)
    1981             format = 'r'*len(row_divs)
    1982             return "\\left" + matrix_delimiters[0] + "\\begin{array}{%s}\n"%format + s + "\n\\end{array}\\right" + matrix_delimiters[1]
    1983 
    1984         # not in EMBEDDED_MODE, or in EMBEDDED_MODE with just a single
    1985         # block: construct one large array, using \hline and vertical
     1935        # construct one large array, using \hline and vertical
    19861936        # bars | in the array descriptor to indicate subdivisions.
    19871937        for r from 0 <= r < nr:
    19881938            if r in row_divs:
  • sage/misc/html.py

    diff --git a/sage/misc/html.py b/sage/misc/html.py
    a b  
    3030    Do the following:
    3131
    3232    * Replace all ``\$ text \$``\'s by
    33       ``<span class='math'> text </span>``
     33      ``<script type="math/tex"> text </script>``
    3434    * Replace all ``\$\$ text \$\$``\'s by
    35       ``<div class='math'> text </div>``
     35      ``<script type="math/tex; mode=display"> text </script>``
    3636    * Replace all ``\ \$``\'s by ``\$``\'s.  Note that in
    3737      the above two cases nothing is done if the ``\$``
    3838      is preceeded by a backslash.
    3939    * Replace all ``\[ text \]``\'s by
    40       ``<div class='math'> text </div>``
     40      ``<script type="math/tex; mode=display"> text </script>``
    4141
    4242    EXAMPLES::
    4343
    4444        sage: sage.misc.html.math_parse('This is $2+2$.')
    45         'This is <span class="math">2+2</span>.'
     45        'This is <script type="math/tex">2+2</script>.'
    4646        sage: sage.misc.html.math_parse('This is $$2+2$$.')
    47         'This is <div class="math">2+2</div>.'
     47        'This is <script type="math/tex; mode=display">2+2</script>.'
    4848        sage: sage.misc.html.math_parse('This is \\[2+2\\].')
    49         'This is <div class="math">2+2</div>.'
     49        'This is <script type="math/tex; mode=display">2+2</script>.'
    5050        sage: sage.misc.html.math_parse(r'This is \[2+2\].')
    51         'This is <div class="math">2+2</div>.'
     51        'This is <script type="math/tex; mode=display">2+2</script>.'
    5252
    5353    TESTS::
    5454
    5555        sage: sage.misc.html.math_parse(r'This \$\$is $2+2$.')
    56         'This $$is <span class="math">2+2</span>.'
     56        'This $$is <script type="math/tex">2+2</script>.'
    5757    """
    58     # first replace \\[ and \\] by <div class="math"> and </div>, respectively.
     58    # first replace \\[ and \\] by <script type="math/tex; mode=display">
     59    # and </script>, respectively.
    5960    while True:
    6061        i = s.find('\\[')
    6162        if i == -1:
    6263            break
    6364        else:
    64             s = s[:i] + '<div class="math">' + s[i+2:]
     65            s = s[:i] + '<script type="math/tex; mode=display">' + s[i+2:]
    6566            j = s.find('\\]')
    6667            if j == -1:  # missing right-hand delimiter, so add one
    67                 s = s + '</div>'
     68                s = s + '</script>'
    6869            else:
    69                 s = s[:j] + '</div>' + s[j+2:]
     70                s = s[:j] + '</script>' + s[j+2:]
    7071   
    7172    # Below t always has the "parsed so far" version of s, and s is
    7273    # just the part of the original input s that hasn't been parsed.
     
    8485            s = s[i+1:]
    8586            continue
    8687        elif i+1 < len(s) and s[i+1] == '$':
    87             # Found a math environment. Double dollar sign so div mode.
    88             typ = 'div'
     88            # Found a math environment. Double dollar sign so display mode.
     89            disp = '; mode=display'
    8990        else:
    90             # Found math environment. Single dollar sign so span mode.
    91             typ = 'span'
     91            # Found math environment. Single dollar sign so default mode.
     92            disp = ''
    9293
    93         # Now find the matching $ sign and form the span or div.
    94         j = s[i+2:].find('$')
    95         if j == -1:
    96             j = len(s)
    97             s += '$'
    98             if typ == 'div':
     94        # Now find the matching $ sign and form the html string.
     95
     96        if len(disp) > 0:
     97            j = s[i+2:].find('$$')
     98            if j == -1:
     99                j = len(s)
    99100                s += '$$'
    100         else:
    101             j += i + 2
    102         if typ == 'div':
     101            else:
     102                j += i + 2
    103103            txt = s[i+2:j]
    104104        else:
     105            j = s[i+2:].find('$')
     106            if j == -1:
     107                j = len(s)
     108                s += '$'
     109            else:
     110                j += i + 2
    105111            txt = s[i+1:j]
    106         t += s[:i] + '<%s class="math">%s</%s>'%(typ,
    107                       ' '.join(txt.splitlines()), typ)
     112
     113        t += s[:i] + '<script type="math/tex%s">%s</script>'%(disp,
     114                      ' '.join(txt.splitlines()))
    108115        s = s[j+1:]
    109         if typ == 'div':
     116        if len(disp) > 0:
    110117            s = s[1:]
    111118    return t
    112119
     
    168175            if j == -1:
    169176                 t += s
    170177                 break
    171             t += s[:i] + '<span class="math">%s</span>'%\
     178            t += s[:i] + '<script type="math/tex">%s</script>'%\
    172179                     latex(sage_eval(s[6+i:j], locals=locals))
    173180            s = s[j+7:]
    174181        print "<html><font color='black'>%s</font></html>"%t
     
    196203            <table class="table_form">
    197204            <tbody>
    198205            <tr class ="row-a">
    199             <td><span class="math">0</span></td>
    200             <td><span class="math">0</span></td>
    201             <td><span class="math">\mathrm{True}</span></td>
     206            <td><script type="math/tex">0</script></td>
     207            <td><script type="math/tex">0</script></td>
     208            <td><script type="math/tex">\mathrm{True}</script></td>
    202209            </tr>
    203210            <tr class ="row-b">
    204             <td><span class="math">0</span></td>
    205             <td><span class="math">1</span></td>
    206             <td><span class="math">\mathrm{False}</span></td>
     211            <td><script type="math/tex">0</script></td>
     212            <td><script type="math/tex">1</script></td>
     213            <td><script type="math/tex">\mathrm{False}</script></td>
    207214            </tr>
    208215            <tr class ="row-a">
    209             <td><span class="math">1</span></td>
    210             <td><span class="math">0</span></td>
    211             <td><span class="math">\mathrm{False}</span></td>
     216            <td><script type="math/tex">1</script></td>
     217            <td><script type="math/tex">0</script></td>
     218            <td><script type="math/tex">\mathrm{False}</script></td>
    212219            </tr>
    213220            <tr class ="row-b">
    214             <td><span class="math">1</span></td>
    215             <td><span class="math">1</span></td>
    216             <td><span class="math">\mathrm{True}</span></td>
     221            <td><script type="math/tex">1</script></td>
     222            <td><script type="math/tex">1</script></td>
     223            <td><script type="math/tex">\mathrm{True}</script></td>
    217224            </tr>
    218225            </tbody>
    219226            </table>
     
    226233            <table class="table_form">
    227234            <tbody>
    228235            <tr>
    229             <th>Functions <span class="math">f(x)</span></th>
     236            <th>Functions <script type="math/tex">f(x)</script></th>
    230237            </tr>
    231238            <tr class ="row-a">
    232             <td><span class="math">\sin\left(x\right)</span></td>
     239            <td><script type="math/tex">\sin\left(x\right)</script></td>
    233240            </tr>
    234241            <tr class ="row-b">
    235             <td><span class="math">\cos\left(x\right)</span></td>
     242            <td><script type="math/tex">\cos\left(x\right)</script></td>
    236243            </tr>
    237244            </tbody>
    238245            </table>
     
    245252            <table class="table_form">
    246253            <tbody>
    247254            <tr>
    248             <th><span class="math">x</span></th>
    249             <th><span class="math">\sin(x)</span></th>
     255            <th><script type="math/tex">x</script></th>
     256            <th><script type="math/tex">\sin(x)</script></th>
    250257            </tr>
    251258            <tr class ="row-a">
    252             <td><span class="math">0</span></td>
    253             <td><span class="math">0.00</span></td>
     259            <td><script type="math/tex">0</script></td>
     260            <td><script type="math/tex">0.00</script></td>
    254261            </tr>
    255262            <tr class ="row-b">
    256             <td><span class="math">1</span></td>
    257             <td><span class="math">0.84</span></td>
     263            <td><script type="math/tex">1</script></td>
     264            <td><script type="math/tex">0.84</script></td>
    258265            </tr>
    259266            <tr class ="row-a">
    260             <td><span class="math">2</span></td>
    261             <td><span class="math">0.91</span></td>
     267            <td><script type="math/tex">2</script></td>
     268            <td><script type="math/tex">0.91</script></td>
    262269            </tr>
    263270            <tr class ="row-b">
    264             <td><span class="math">3</span></td>
    265             <td><span class="math">0.14</span></td>
     271            <td><script type="math/tex">3</script></td>
     272            <td><script type="math/tex">0.14</script></td>
    266273            </tr>
    267274            </tbody>
    268275            </table>
     
    306313        TESTS::
    307314       
    308315            sage: html._table_columns(["a $x^2$",1, sin(x)])
    309             <td>a <span class="math">x^2</span></td>
    310             <td><span class="math">1</span></td>
    311             <td><span class="math">\sin\left(x\right)</span></td>
     316            <td>a <script type="math/tex">x^2</script></td>
     317            <td><script type="math/tex">1</script></td>
     318            <td><script type="math/tex">\sin\left(x\right)</script></td>
    312319            sage: html._table_columns("a", header=True)
    313320            <th>a</th>
    314321        """       
     
    326333            elif isinstance(row[column], str):
    327334                print column_tag % math_parse(row[column])
    328335            else:
    329                 print column_tag % ('<span class="math">%s</span>' % latex(row[column]))
     336                print column_tag % ('<script type="math/tex">%s</script>' % latex(row[column]))
    330337
    331338    def iframe(self, url, height=400, width=800):
    332339        r"""
  • sage/misc/latex.py

    diff --git a/sage/misc/latex.py b/sage/misc/latex.py
    a b  
    323323    # 2) wrap each line into \verb;
    324324    # 3) assemble lines into a left-justified array.
    325325   
    326     # There is a bug in verb-space treatment in jsMath...
    327     spacer = "\\phantom{%s}"
    328     # \phantom{\verb!%s!} is more accurate and it works, but it is not a valid
    329     # LaTeX and may cause problems, so let's live with the above variant until
    330     # spaces are properly treated in jsMath/MathJax and we don't need to worry.
     326    spacer = r"\phantom{\verb!%s!}"
    331327    lines = []
    332328    for line in x.split("\n"):
    333329        parts = []
     
    583579        self._option["preamble"] = ""
    584580        self._option["engine"] = "latex"
    585581        self._option["engine_name"] = "LaTeX"
    586         self._option["jsmath_avoid"] = []
     582        self._option["mathjax_avoid"] = []
    587583
    588584_Latex_prefs = _Latex_prefs_object()
    589585
     
    10911087        """
    10921088        if t is None:
    10931089            return _Latex_prefs._option["blackboard_bold"]
    1094         from latex_macros import sage_latex_macros, sage_jsmath_macros, sage_configurable_latex_macros, convert_latex_macro_to_jsmath
     1090        from latex_macros import sage_latex_macros, sage_mathjax_macros, sage_configurable_latex_macros, convert_latex_macro_to_mathjax
    10951091        global sage_latex_macros
    1096         global sage_jsmath_macros
     1092        global sage_mathjax_macros
    10971093        old = _Latex_prefs._option["blackboard_bold"]
    10981094        _Latex_prefs._option["blackboard_bold"] = bool(t)
    10991095        if bool(old) != bool(t):
     
    11091105            sage_configurable_latex_macros.remove(old_macro)
    11101106            sage_latex_macros.append(macro)
    11111107            sage_configurable_latex_macros.append(macro)
    1112             sage_jsmath_macros.remove(convert_latex_macro_to_jsmath(old_macro))
    1113             sage_jsmath_macros.append(convert_latex_macro_to_jsmath(macro))
     1108            sage_mathjax_macros.remove(convert_latex_macro_to_mathjax(old_macro))
     1109            sage_mathjax_macros.append(convert_latex_macro_to_mathjax(macro))
    11141110
    11151111    def matrix_delimiters(self, left=None, right=None):
    11161112        r"""nodetex
     
    12881284    def extra_macros(self, macros=None):
    12891285        r"""nodetex
    12901286        String containing extra LaTeX macros to use with %latex,
    1291         %html, and %jsmath.
     1287        %html, and %mathjax.
    12921288
    12931289        INPUT: ``macros`` - string
    12941290
     
    13131309    def add_macro(self, macro):
    13141310        r"""nodetex
    13151311        Append to the string of extra LaTeX macros, for use with
    1316         %latex, %html, and %jsmath.
     1312        %latex, %html, and %mathjax.
    13171313
    13181314        INPUT: ``macro`` - string
    13191315
     
    13331329    def extra_preamble(self, s=None):
    13341330        r"""nodetex
    13351331        String containing extra preamble to be used with %latex.
    1336         Anything in this string won't be processed by %jsmath.
     1332        Anything in this string won't be processed by %mathjax.
    13371333
    13381334        INPUT: ``s`` - string or ``None``
    13391335
     
    13671363        r"""nodetex
    13681364        Append to the string of extra LaTeX macros, for use with
    13691365        %latex.  Anything in this string won't be processed by
    1370         %jsmath.
     1366        %mathjax.
    13711367
    13721368        EXAMPLES::
    13731369
     
    14331429        if self.has_file(package_name+".sty"):
    14341430            self.add_to_preamble("\\usepackage{%s}\n"%package_name)
    14351431
    1436     def jsmath_avoid_list(self, L=None):
     1432    def mathjax_avoid_list(self, L=None):
    14371433        r"""nodetex
    1438         List of strings which signal that jsMath should not
     1434        List of strings which signal that MathJax should not
    14391435        be used when 'view'ing.
    14401436
    14411437        INPUT: ``L`` - list or ``None``
     
    14431439        If ``L`` is ``None``, then return the current list.
    14441440        Otherwise, set it to ``L``.  If you want to *append* to the
    14451441        current list instead of replacing it, use
    1446         :meth:`latex.add_to_jsmath_avoid_list <Latex.add_to_jsmath_avoid_list>`.
     1442        :meth:`latex.add_to_mathjax_avoid_list <Latex.add_to_mathjax_avoid_list>`.
    14471443
    14481444        EXAMPLES::
    14491445
    1450             sage: latex.jsmath_avoid_list(["\\mathsf", "pspicture"])
    1451             sage: latex.jsmath_avoid_list()  # display current setting
     1446            sage: latex.mathjax_avoid_list(["\\mathsf", "pspicture"])
     1447            sage: latex.mathjax_avoid_list()  # display current setting
    14521448            ['\\mathsf', 'pspicture']
    1453             sage: latex.jsmath_avoid_list([])  # reset to default
    1454             sage: latex.jsmath_avoid_list()
     1449            sage: latex.mathjax_avoid_list([])  # reset to default
     1450            sage: latex.mathjax_avoid_list()
    14551451            []
    14561452        """
    14571453        if L is None:
    1458             return _Latex_prefs._option['jsmath_avoid']
     1454            return _Latex_prefs._option['mathjax_avoid']
    14591455        else:
    1460             _Latex_prefs._option['jsmath_avoid'] = L
    1461 
    1462     def add_to_jsmath_avoid_list(self, s):
     1456            _Latex_prefs._option['mathjax_avoid'] = L
     1457
     1458    def add_to_mathjax_avoid_list(self, s):
    14631459        r"""nodetex
    1464         Add to the list of strings which signal that jsMath should not
     1460        Add to the list of strings which signal that MathJax should not
    14651461        be used when 'view'ing.
    14661462
    1467         INPUT: ``s`` - string -- add ``s`` to the list of 'jsMath avoid' strings
     1463        INPUT: ``s`` - string -- add ``s`` to the list of 'MathJax avoid' strings
    14681464
    14691465        If you want to replace the current list instead of adding to
    1470         it, use :meth:`latex.jsmath_avoid_list <Latex.jsmath_avoid_list>`.
     1466        it, use :meth:`latex.mathjax_avoid_list <Latex.mathjax_avoid_list>`.
    14711467
    14721468        EXAMPLES::
    14731469
    1474             sage: latex.add_to_jsmath_avoid_list("\\mathsf")
    1475             sage: latex.jsmath_avoid_list()  # display current setting
     1470            sage: latex.add_to_mathjax_avoid_list("\\mathsf")
     1471            sage: latex.mathjax_avoid_list()  # display current setting
    14761472            ['\\mathsf']
    1477             sage: latex.add_to_jsmath_avoid_list("tkz-graph")
    1478             sage: latex.jsmath_avoid_list()  # display current setting
     1473            sage: latex.add_to_mathjax_avoid_list("tkz-graph")
     1474            sage: latex.mathjax_avoid_list()  # display current setting
    14791475            ['\\mathsf', 'tkz-graph']
    1480             sage: latex.jsmath_avoid_list([])  # reset to default
    1481             sage: latex.jsmath_avoid_list()
     1476            sage: latex.mathjax_avoid_list([])  # reset to default
     1477            sage: latex.mathjax_avoid_list()
    14821478            []
    14831479        """
    1484         current = latex.jsmath_avoid_list()
     1480        current = latex.mathjax_avoid_list()
    14851481        if s not in current:
    1486             _Latex_prefs._option['jsmath_avoid'].append(s)
     1482            _Latex_prefs._option['mathjax_avoid'].append(s)
    14871483
    14881484    def pdflatex(self, t = None):  # this is deprecated since 4.3.3
    14891485        """
     
    17031699
    17041700    return s
    17051701
    1706 class JSMathExpr:
     1702class MathJaxExpr:
    17071703    """
    1708     An arbitrary JSMath expression that can be nicely concatenated.
     1704    An arbitrary MathJax expression that can be nicely concatenated.
    17091705
    17101706    EXAMPLES::
    17111707
    1712         sage: from sage.misc.latex import JSMathExpr
    1713         sage: JSMathExpr("a^{2}") + JSMathExpr("x^{-1}")
     1708        sage: from sage.misc.latex import MathJaxExpr
     1709        sage: MathJaxExpr("a^{2}") + MathJaxExpr("x^{-1}")
    17141710        a^{2}x^{-1}
    17151711    """
    17161712    def __init__(self, y):
    17171713        """
    1718         Initialize a JSMath expression.
     1714        Initialize a MathJax expression.
    17191715
    17201716        INPUT:
    17211717
     
    17251721
    17261722        EXAMPLES::
    17271723
    1728             sage: from sage.misc.latex import JSMathExpr
    1729             sage: js = JSMathExpr(3); js  # indirect doctest
     1724            sage: from sage.misc.latex import MathJaxExpr
     1725            sage: jax = MathJaxExpr(3); jax  # indirect doctest
    17301726            3
    17311727        """
    17321728        self.__y = y
     
    17371733
    17381734        EXAMPLES::
    17391735
    1740             sage: from sage.misc.latex import JSMathExpr
    1741             sage: js = JSMathExpr('3')
    1742             sage: js.__repr__()
     1736            sage: from sage.misc.latex import MathJaxExpr
     1737            sage: jax = MathJaxExpr('3')
     1738            sage: jax.__repr__()
    17431739            '3'
    17441740        """
    17451741        return str(self.__y)
    17461742
    17471743    def __add__(self, y):
    17481744        """
    1749         'Add' JSMathExpr ``self`` to ``y``.  This concatenates them
     1745        'Add' MathJaxExpr ``self`` to ``y``.  This concatenates them
    17501746        (assuming that they're strings).
    17511747
    17521748        EXAMPLES::
    17531749
    1754             sage: from sage.misc.latex import JSMathExpr
    1755             sage: j3 = JSMathExpr('3')
    1756             sage: jx = JSMathExpr('x')
     1750            sage: from sage.misc.latex import MathJaxExpr
     1751            sage: j3 = MathJaxExpr('3')
     1752            sage: jx = MathJaxExpr('x')
    17571753            sage: j3 + jx
    17581754            3x
    17591755        """
    1760         return JSMathExpr(self.__y + y)
     1756        return MathJaxExpr(self.__y + y)
    17611757
    17621758    def __radd__(self, y):
    17631759        """
    1764         'Add' JSMathExpr ``y`` to ``self``.  This concatenates them
     1760        'Add' MathJaxExpr ``y`` to ``self``.  This concatenates them
    17651761        (assuming that they're strings).
    17661762
    17671763        EXAMPLES::
    17681764
    1769             sage: from sage.misc.latex import JSMathExpr
    1770             sage: j3 = JSMathExpr('3')
    1771             sage: jx = JSMathExpr('x')
     1765            sage: from sage.misc.latex import MathJaxExpr
     1766            sage: j3 = MathJaxExpr('3')
     1767            sage: jx = MathJaxExpr('x')
    17721768            sage: j3.__radd__(jx)
    17731769            x3
    17741770        """
    1775         return JSMathExpr(y + self.__y)
    1776 
    1777 class JSMath:
     1771        return MathJaxExpr(y + self.__y)
     1772
     1773class MathJax:
    17781774    r"""
    1779     Render LaTeX input using JSMath.  This returns a :class:`JSMathExpr`.
     1775    Render LaTeX input using MathJax.  This returns a :class:`MathJaxExpr`.
    17801776
    17811777    EXAMPLES::
    17821778
    1783         sage: from sage.misc.latex import JSMath
    1784         sage: JSMath()(3)
    1785         <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}3</div></html>
    1786         sage: JSMath()(ZZ)
    1787         <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}</div></html>
     1779        sage: from sage.misc.latex import MathJax
     1780        sage: MathJax()(3)
     1781        <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}3</script></html>
     1782        sage: MathJax()(ZZ)
     1783        <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}</script></html>
    17881784    """
    17891785
    17901786    def __call__(self, x, combine_all=False):
    17911787        r"""
    1792         Render LaTeX input using JSMath.  This returns a :class:`JSMathExpr`.
     1788        Render LaTeX input using MathJax.  This returns a :class:`MathJaxExpr`.
    17931789
    17941790        INPUT:
    17951791
     
    18001796          and instead returns a string with all the elements separated by
    18011797          a single space.
    18021798
    1803         OUTPUT: a JSMathExpr
     1799        OUTPUT: a MathJaxExpr
    18041800
    18051801        EXAMPLES::
    18061802
    1807             sage: from sage.misc.latex import JSMath
    1808             sage: JSMath()(3)
    1809             <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}3</div></html>
    1810             sage: str(JSMath().eval(ZZ[x], mode='display')) == str(JSMath()(ZZ[x]))
     1803            sage: from sage.misc.latex import MathJax
     1804            sage: MathJax()(3)
     1805            <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}3</script></html>
     1806            sage: str(MathJax().eval(ZZ[x], mode='display')) == str(MathJax()(ZZ[x]))
    18111807            True
    18121808        """
    18131809        return self.eval(x, combine_all=combine_all)
     
    18151811    def eval(self, x, globals=None, locals=None, mode='display',
    18161812            combine_all=False):
    18171813        r"""
    1818         Render LaTeX input using JSMath.  This returns a :class:`JSMathExpr`.
     1814        Render LaTeX input using MathJax.  This returns a :class:`MathJaxExpr`.
    18191815
    18201816        INPUT:
    18211817
     
    18341830          and instead returns a string with all the elements separated by
    18351831          a single space.
    18361832
    1837         OUTPUT: a JSMathExpr
     1833        OUTPUT: a MathJaxExpr
    18381834
    18391835        EXAMPLES::
    18401836
    1841             sage: from sage.misc.latex import JSMath
    1842             sage: JSMath().eval(3, mode='display')
    1843             <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}3</div></html>
    1844             sage: JSMath().eval(3, mode='inline')
    1845             <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}3</span></html>
    1846             sage: JSMath().eval(type(3), mode='inline')
    1847             <html>...\verb|&lt;type|\phantom{x}\verb|'sage.rings.integer.Integer'&gt;|</span></html>
    1848             sage: JSMath().eval((1,3), mode='display', combine_all=True)
    1849             <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}1 3</div></html>
     1837            sage: from sage.misc.latex import MathJax
     1838            sage: MathJax().eval(3, mode='display')
     1839            <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}3</script></html>
     1840            sage: MathJax().eval(3, mode='inline')
     1841            <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}3</script></html>
     1842            sage: MathJax().eval(type(3), mode='inline')
     1843            <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\verb|&lt;type|\phantom{\verb!x!}\verb|'sage.rings.integer.Integer'&gt;|</script></html>
    18501844        """
    18511845        # Get a regular LaTeX representation of x...
    18521846        x = latex(x, combine_all=combine_all)
    1853         # ... and make it suitable for jsMath, which has issues with < and >.
     1847        # ... and make it suitable for MathJax and html
    18541848        x = x.replace('<', '&lt;').replace('>', '&gt;')
    1855         # In jsMath:
    1856         #   inline math: <span class="math">...</span>
    1857         #   displaymath: <div class="math">...</div>
     1849        # In MathJax:
     1850        #   inline math: <script type="math/tex">...</script>
     1851        #   displaymath: <script type="math/tex; mode=display">...</script>
    18581852        from sage.misc.latex_macros import sage_configurable_latex_macros
    1859         if 'display' == mode:
    1860             return JSMathExpr('<html><div class="math">'
    1861                               + ''.join(sage_configurable_latex_macros)
    1862                               + _Latex_prefs._option['macros']
    1863                               + '%s</div></html>'%x)
    1864         elif 'inline' == mode:
    1865             return JSMathExpr('<html><span class="math">'
    1866                               + ''.join(sage_configurable_latex_macros)
    1867                               + _Latex_prefs._option['macros']
    1868                               + '%s</span></html>'%x)
     1853        if mode == 'display':
     1854            modecode = '; mode=display'
     1855        elif mode == 'inline':
     1856            modecode = ''
    18691857        else:
    18701858            # what happened here?
    1871             raise ValueError, "mode must be either 'display' or 'inline'"
    1872 
    1873 def jsmath(x, mode='display'):
    1874     r"""
    1875     Attempt to nicely render an arbitrary Sage object with jsMath typesetting.
    1876     Tries to call ._latex_() on x. If that fails, it will render a string
    1877     representation of x.
    1878 
    1879     .. warning::
    1880 
    1881         2009-04: This function is deprecated; use :func:`~.html.html`
    1882         instead: replace ``jsmath('MATH', mode='display')`` with
    1883         ``html('$$MATH$$')``, and replace ``jsmath('MATH',
    1884         mode='inline')`` with ``html('$MATH$')``.
    1885 
    1886     INPUT:
    1887         x -- the object to render
    1888         mode -- 'display' for displaymath or 'inline' for inline math
    1889 
    1890     OUTPUT:
    1891         A string of html that contains the LaTeX representation of x. In the
    1892         notebook this gets embedded into the cell.
    1893 
    1894     EXAMPLES::
    1895 
    1896         sage: from sage.misc.latex import jsmath
    1897         sage: f = maxima('1/(x^2+1)')
    1898         sage: g = f.integrate()
    1899         sage: jsmath(f)
    1900         doctest:1: DeprecationWarning: The jsmath function is deprecated.  Use html('$math$') for inline mode or html('$$math$$') for display mode.
    1901         See http://trac.sagemath.org/8552 for details.
    1902         <html><font color='black'><div class="math">{{1}\over{x^2+1}}</div></font></html>
    1903         <BLANKLINE>
    1904         sage: jsmath(g, 'inline')
    1905         <html><font color='black'><span class="math">\tan^{-1} x</span></font></html>
    1906         sage: jsmath('\int' + latex(f) + '\ dx=' + latex(g))
    1907         <html><font color='black'><div class="math">\int {{1}\over{x^2+1}} \ dx= \tan^{-1} x</div></font></html>
    1908 
    1909     AUTHORS:
    1910 
    1911     - William Stein (2006-10): general layout (2006-10)
    1912 
    1913     - Bobby Moretti (2006-10): improvements, comments, documentation
    1914     """
    1915     from sage.misc.superseded import deprecation
    1916     from sage.misc.html import html
    1917     deprecation(8552, "The jsmath function is deprecated.  Use html('$math$') for inline mode or html('$$math$$') for display mode.")
    1918     if mode == 'display':
    1919         delimiter = '$$'
    1920     elif mode == 'inline':
    1921         delimiter = '$'
    1922     else:
    1923         raise ValueError, "mode must be either 'display' or 'inline'"
    1924     try:
    1925         # try to get a latex representation of the object
    1926         x = x._latex_()
    1927     except AttributeError:
    1928         # otherwise just get the string representation
    1929         x = str(x)
    1930     return html(delimiter + x + delimiter)
     1859            raise ValueError("mode must be either 'display' or 'inline'")
     1860
     1861        return MathJaxExpr('<html><script type="math/tex{0}">'.format(modecode)
     1862                         + ''.join(sage_configurable_latex_macros)
     1863                         + _Latex_prefs._option['macros']
     1864                         + '{0}</script></html>'.format(x))
    19311865
    19321866def view(objects, title='SAGE', debug=False, sep='', tiny=False,
    19331867        pdflatex=None, engine=None, viewer = None, tightpage = None,
     
    20181952    each object by ``\\begin{page}$`` and ``$\\end{page}``.
    20191953
    20201954    If in notebook mode with ``viewer`` equal to ``None``, this
    2021     usually uses jsMath -- see the next paragraph for the exception --
     1955    usually uses MathJax -- see the next paragraph for the exception --
    20221956    to display the output in the notebook. Only the first argument,
    20231957    ``objects``, is relevant; the others are ignored. If ``objects``
    20241958    is a list, each object is printed on its own line.
    20251959
    2026     In the notebook, this *does* *not* use jsMath if the LaTeX code
     1960    In the notebook, this *does* *not* use MathJax if the LaTeX code
    20271961    for ``objects`` contains a string in
    2028     :meth:`latex.jsmath_avoid_list() <Latex.jsmath_avoid_list>`.  In
     1962    :meth:`latex.mathjax_avoid_list() <Latex.mathjax_avoid_list>`.  In
    20291963    this case, it creates and displays a png file.
    20301964
    20311965    EXAMPLES::
    20321966
    20331967        sage: sage.misc.latex.EMBEDDED_MODE = True
    20341968        sage: view(3)
    2035         <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}3</span></html>
     1969        <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}3</script></html>
    20361970        sage: view(3, mode='display')
    2037         <html><div class="math">\newcommand{\Bold}[1]{\mathbf{#1}}3</div></html>
     1971        <html><script type="math/tex; mode=display">\newcommand{\Bold}[1]{\mathbf{#1}}3</script></html>
    20381972        sage: view((x,2), combine_all=True) # trac 11775
    2039         <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}x 2</span></html>
     1973        <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}x 2</script></html>
    20401974        sage: sage.misc.latex.EMBEDDED_MODE = False
    20411975
    20421976    TESTS::
     
    20742008        engine = "pdflatex"
    20752009    # notebook
    20762010    if EMBEDDED_MODE and viewer is None:
    2077         jsMath_okay = True
    2078         for t in latex.jsmath_avoid_list():
     2011        MathJax_okay = True
     2012        for t in latex.mathjax_avoid_list():
    20792013            if s.find(t) != -1:
    2080                 jsMath_okay = False
    2081             if not jsMath_okay:
     2014                MathJax_okay = False
     2015            if not MathJax_okay:
    20822016                break
    2083         if jsMath_okay:  # put comma at end of line in print below?
    2084             print JSMath().eval(objects, mode=mode, combine_all=combine_all)
     2017        if MathJax_okay:  # put comma at end of line below?
     2018            print MathJax().eval(objects, mode=mode, combine_all=combine_all)
    20852019        else:
    20862020            base_dir = os.path.abspath("")
    20872021            png_file = graphics_filename(ext='png')
     
    22882222        sage: TEMP = sys.displayhook
    22892223        sage: sys.displayhook = sage.misc.latex.pretty_print
    22902224        sage: sage.misc.latex.print_or_typeset(3)
    2291         <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}3</span></html>
     2225        <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}3</script></html>
    22922226        sage: sage.misc.latex.EMBEDDED_MODE=False
    22932227        sage: sys.displayhook = TEMP
    22942228    """
     
    23042238    objects, this returns their default representation.  For other
    23052239    objects, in the notebook, this calls the :func:`view` command,
    23062240    while from the command line, this produces an html string suitable
    2307     for processing by jsMath.
     2241    for processing by MathJax.
    23082242
    23092243    INPUT:
    23102244
     
    23172251    EXAMPLES::
    23182252
    23192253        sage: pretty_print(ZZ)  # indirect doctest
    2320         <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}</span></html>
     2254        <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\Bold{Z}</script></html>
    23212255        sage: pretty_print("Integers = ", ZZ) # trac 11775
    2322         <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\verb|Integers|\phantom{x}\verb|=| \Bold{Z}</span></html>
     2256        <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\verb|Integers|\phantom{\verb!x!}\verb|=| \Bold{Z}</script></html>
    23232257
    23242258    To typeset LaTeX code as-is, use :class:`LatexExpr`::
    23252259
    23262260        sage: pretty_print(LatexExpr(r"\frac{x^2 + 1}{x - 2}"))
    2327         <html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{x^2 + 1}{x - 2}</span></html>
     2261        <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\frac{x^2 + 1}{x - 2}</script></html>
    23282262    """
    23292263    # view s if it is not empty. Used twice.
    23302264    def _show_s(s):
     
    23322266            if EMBEDDED_MODE:
    23332267                view(tuple(s), combine_all=True)
    23342268            else:
    2335                 print JSMath().eval(tuple(s), mode='inline',
     2269                print MathJax().eval(tuple(s), mode='inline',
    23362270                        combine_all=True)
    23372271
    23382272    s = []
     
    23582292def pretty_print_default(enable=True):
    23592293    r"""
    23602294    Enable or disable default pretty printing. Pretty printing means
    2361     rendering things so that jsMath or some other latex-aware front end
     2295    rendering things so that MathJax or some other latex-aware front end
    23622296    can render real math.
    23632297
    23642298    INPUT:
     
    23702304
    23712305        sage: pretty_print_default(True)
    23722306        sage: sys.displayhook
    2373         <html>...\verb|&lt;function|\phantom{x}\verb|pretty_print|...</html>
     2307        <html><script type="math/tex">\newcommand{\Bold}[1]{\mathbf{#1}}\verb|&lt;function|\phantom{\verb!x!}\verb|pretty_print|\phantom{\verb!x!}\verb|at|\phantom{\verb!x!}\verb|...|</script></html>
    23742308        sage: pretty_print_default(False)
    23752309        sage: sys.displayhook == sys.__displayhook__
    23762310        True
     
    25962530the TeX package pgf installed, along with the LaTeX package tkz-graph.
    25972531Run 'latex.add_to_preamble("\\usepackage{tkz-graph}")', and try viewing
    25982532it again.  From the command line, this should pop open a nice window
    2599 with a picture of a graph.  In the notebook, you should get a jsMath
    2600 error.  Finally, run 'latex.add_to_jsmath_avoid_list("tikzpicture")'
     2533with a picture of a graph.  In the notebook, you should get a MathJax
     2534error.  Finally, run 'latex.add_to_mathjax_avoid_list("tikzpicture")'
    26012535and try again from the notebook -- you should get a nice picture.
    26022536
    26032537(LaTeX code taken from http://altermundus.com/pages/graph.html)
     
    26792613open a nice window with a picture of forces acting on a mass
    26802614on a pendulum. In the notebook, you should get an error.
    26812615Finally, run
    2682 'latex.add_to_jsmath_avoid_list("pspicture")' and try again
     2616'latex.add_to_mathjax_avoid_list("pspicture")' and try again
    26832617-- you should get a nice picture."""
    26842618
    26852619        def _latex_(self):
     
    27462680'latex.add_to_preamble("\\usepackage[graph,knot,poly,curve]{xypic}")',
    27472681and try viewing again -- it should work in the command line but not
    27482682from the notebook.  In the notebook, run
    2749 'latex.add_to_jsmath_avoid_list("xygraph")' and try again -- you
     2683'latex.add_to_mathjax_avoid_list("xygraph")' and try again -- you
    27502684should get a nice picture.
    27512685
    27522686(LaTeX code taken from the xypic manual)
     
    28102744'latex.add_to_preamble("\\usepackage[matrix,arrow,curve,cmtip]{xy}")',
    28112745and try viewing again -- it should work in the command line but not
    28122746from the notebook.  In the notebook, run
    2813 'latex.add_to_jsmath_avoid_list("xymatrix")' and try again -- you
     2747'latex.add_to_mathjax_avoid_list("xymatrix")' and try again -- you
    28142748should get a picture (a part of the diagram arising from a filtered
    28152749chain complex)."""
    28162750
  • sage/misc/latex_macros.py

    diff --git a/sage/misc/latex_macros.py b/sage/misc/latex_macros.py
    a b  
    99documentation. To add a macro, modify the list ``macros``, near the
    1010end of this file, and then run 'sage -b'. The entries in this list are
    1111used to produce ``sage_latex_macros``, a list of strings of the form
    12 '\\newcommand...', and ``sage_js_macros``, a list of strings of the
    13 form 'jsMath.Macro...'.  The LaTeX macros are produced using the
    14 ``_latex_`` method for each Sage object listed in ``macros``, and the
    15 jsMath macros are produced from the LaTeX macros.  The list of LaTeX
    16 macros is used in the file ``SAGE_ROOT/devel/sage/doc/common/conf.py``
    17 to add to the preambles of both the LaTeX file used to build the PDF
    18 version of the documentation and the LaTeX file used to build the HTML
    19 version.  The list of jsMath macros is used in the file
    20 ``sage/server/notebook/notebook.py`` to define jsMath macros for use
     12'\\newcommand...', and ``sage_mathjax_macros``, a list of strings
     13suitable for parsing by MathJax.  The LaTeX macros are produced using
     14the ``_latex_`` method for each Sage object listed in ``macros``, and
     15the MathJax macros are produced from the LaTeX macros.  The list of
     16LaTeX macros is used in the file
     17``SAGE_ROOT/devel/sage/doc/common/conf.py`` to add to the preambles of
     18both the LaTeX file used to build the PDF version of the documentation
     19and the LaTeX file used to build the HTML version.  The list of
     20MathJax macros is used in the file
     21``sage/server/notebook/notebook.py`` to define MathJax macros for use
    2122in the live documentation (and also in the notebook).
    2223
    2324Any macro defined here may be used in docstrings or in the tutorial
     
    101102        defn = defn.replace(str(x), "#" + str(count))
    102103    return newcommand + defn
    103104
    104 def convert_latex_macro_to_jsmath(macro):
     105def convert_latex_macro_to_mathjax(macro):
    105106    r"""
    106107    This converts a LaTeX macro definition (\newcommand...) to a
    107     jsMath macro definition (jsMath.Macro...).
     108    MathJax macro definition (MathJax.Macro...).
    108109
    109110    INPUT:
    110111
    111112    -  ``macro`` - LaTeX macro definition
    112113
    113114    See the web page
    114     http://www.math.union.edu/~dpvc/jsMath/authors/macros.html for a
    115     description of the format for jsMath macros.
     115    http://www.mathjax.org/docs/1.1/options/TeX.html for a
     116    description of the format for MathJax macros.
    116117
    117118    EXAMPLES::
    118119
    119         sage: from sage.misc.latex_macros import convert_latex_macro_to_jsmath
    120         sage: convert_latex_macro_to_jsmath('\\newcommand{\\ZZ}{\\Bold{Z}}')
    121         "jsMath.Macro('ZZ','\\\\Bold{Z}');"
    122         sage: convert_latex_macro_to_jsmath('\\newcommand{\\GF}[1]{\\Bold{F}_{#1}}')
    123         "jsMath.Macro('GF','\\\\Bold{F}_{#1}',1);"
     120        sage: from sage.misc.latex_macros import convert_latex_macro_to_mathjax
     121        sage: convert_latex_macro_to_mathjax('\\newcommand{\\ZZ}{\\Bold{Z}}')
     122        'ZZ: "\\\\Bold{Z}"'
     123        sage: convert_latex_macro_to_mathjax('\\newcommand{\\GF}[1]{\\Bold{F}_{#1}}')
     124        'GF: ["\\\\Bold{F}_{#1}",1]'
    124125    """
    125126    left_bracket = macro.find('[')
    126127    right_bracket = macro.find('[')
     
    135136    start_defn = macro.find('{', end_name)
    136137    end_defn = macro.rfind('}')
    137138    defn = macro[start_defn+1: end_defn].replace('\\', '\\\\')
    138     if num_args > 0:
    139         args_str = "," + str(num_args)
     139    if num_args == 0:
     140        return name + ': "' + defn + '"'
    140141    else:
    141         args_str = ""
    142     return "jsMath.Macro('" + name + "','" + defn + "'" + args_str + ");"
    143 
    144 def convert_latex_macro_to_jsmath_easy(macro):
    145     r"""
    146     This converts a LaTeX macro definition (\newcommand...) to a
    147     definition for jsMath's easy/load.js macro array.
    148 
    149     INPUT:
    150 
    151     -  ``macro`` - LaTeX macro definition
    152 
    153     EXAMPLES::
    154 
    155         sage: from sage.misc.latex_macros import convert_latex_macro_to_jsmath_easy
    156         sage: convert_latex_macro_to_jsmath_easy('\\newcommand{\\ZZ}{\\Bold{Z}}')
    157         "ZZ : '{\\\\Bold{Z}}'"
    158         sage: convert_latex_macro_to_jsmath_easy('\\newcommand{\\GF}[1]{\\Bold{F}_{#1}}')
    159         "GF : ['{\\\\Bold{F}_{#1}}', 1]"
    160     """
    161     left_bracket = macro.find('[')
    162     right_bracket = macro.find('[')
    163     if left_bracket >= 0:
    164         right_bracket = macro.find(']')
    165         num_args = macro[left_bracket+1:right_bracket]
    166     else:
    167         num_args = 0
    168     start_name = macro.find('{') + 1  # add one to go past the backslash
    169     end_name = macro.find('}')
    170     name = macro[start_name+1:end_name]
    171     start_defn = macro.find('{', end_name)
    172     end_defn = macro.rfind('}')
    173     defn = macro[start_defn+1: end_defn].replace('\\', '\\\\')
    174     if num_args > 0:
    175         args_str = "," + str(num_args)
    176         return name + " : ['{" + defn + "}', " + str(num_args) + ']'
    177     else:
    178         return name + " : '{" + defn + "}'"
     142        return name + ': ["' + defn + '",' + str(num_args) + ']'
    179143
    180144# To add a new macro for use in the Sage documentation, add a list or
    181145# tuple to the following list.  Each list (or tuple) should have the
     
    213177
    214178sage_latex_macros += sage_configurable_latex_macros
    215179
    216 # jsMath macro definitions as JavaScript, e.g., to include in HTML
     180# MathJax macro definitions as JavaScript, e.g., to include in HTML
    217181# script elements.
    218 sage_jsmath_macros = [convert_latex_macro_to_jsmath(m) for m in sage_latex_macros]
    219 
    220 # jsMath macro definitions for an easy/load.js file's "macros" array.
    221 sage_jsmath_macros_easy = [convert_latex_macro_to_jsmath_easy(m) for m in sage_latex_macros]
     182sage_mathjax_macros = [convert_latex_macro_to_mathjax(m) for m in sage_latex_macros]
  • sage/misc/sagedoc.py

    diff --git a/sage/misc/sagedoc.py b/sage/misc/sagedoc.py
    a b  
    4242
    4343# two kinds of substitutions: math, which should only be done on the
    4444# command line -- in the notebook, these should instead by taken care
    45 # of by jsMath -- and nonmath, which should be done always.
     45# of by MathJax -- and nonmath, which should be done always.
    4646math_substitutes = [ # don't forget leading backslash '\\'
    4747    ('\\to', '-->'),
    4848    ('\\leq', '<='),
     
    347347                       s, count=1)
    348348    return s
    349349
    350 def process_mathtt(s, embedded=False):
     350def process_mathtt(s):
    351351    r"""nodetex
    352     Replace \\mathtt{BLAH} with either \\verb|BLAH| (in the notebook) or
    353     BLAH (from the command line).
     352    Replace \\mathtt{BLAH} with BLAH in the command line.
    354353
    355354    INPUT:
    356355
    357356    - ``s`` - string, in practice a docstring
    358     - ``embedded`` - boolean (optional, default False)
    359357
    360     This function is called by :func:`format`, and if in the notebook,
    361     it sets ``embedded`` to be ``True``, otherwise ``False``.
     358    This function is called by :func:`format`.
    362359
    363360    EXAMPLES::
    364361
    365362        sage: from sage.misc.sagedoc import process_mathtt
    366363        sage: process_mathtt(r'e^\mathtt{self}')
    367364        'e^self'
    368         sage: process_mathtt(r'e^\mathtt{self}', embedded=True)
    369         'e^{\\verb|self|}'
    370365    """
    371     replaced = False
    372366    while True:
    373367        start = s.find("\\mathtt{")
    374368        end = s.find("}", start)
    375369        if start == -1 or end == -1:
    376370            break
    377         if embedded:
    378             left = "{\\verb|"
    379             right = "|}"
    380         else:
    381             left = ""
    382             right = ""
    383         s = s[:start] + left + s[start+8:end] + right + s[end+1:]
     371        s = s[:start] + s[start+8:end] + s[end+1:]
    384372    return s
    385373
    386374def format(s, embedded=False):
     
    569557
    570558    if 'nodetex' not in directives:
    571559        s = process_dollars(s)
    572         s = process_mathtt(s, embedded=embedded)
     560        if not embedded:
     561            s = process_mathtt(s)
    573562        s = process_extlinks(s, embedded=embedded)
    574563        s = detex(s, embedded=embedded)
    575564    return embedding_info+s
     
    13311320    </script>
    13321321    <script type="text/javascript" src="%(static_path)s/jquery.js"></script>
    13331322    <script type="text/javascript" src="%(static_path)s/doctools.js"></script>
    1334     <script type="text/javascript" src="%(static_path)s/jsmath_sage.js"></script>
     1323    <script type="text/javascript" src="%(static_path)s/mathjax_sage.js"></script>
    13351324    <link rel="shortcut icon" href="%(static_path)s/favicon.ico" />
    13361325    <link rel="icon" href="%(static_path)s/sageicon.png" type="image/x-icon" />
    13371326  </head>
     
    13891378        path = os.path.join(self._base_path, name, "index.html")
    13901379        if not os.path.exists(path):
    13911380            raise OSError, """The document '%s' does not exist.  Please build it
    1392 with 'sage -docbuild %s html --jsmath' and try again.""" %(name, name)
     1381with 'sage -docbuild %s html --mathjax' and try again.""" %(name, name)
    13931382
    13941383        if testing:
    13951384            return (url, path)
  • sage/modules/vector_callable_symbolic_dense.py

    diff --git a/sage/modules/vector_callable_symbolic_dense.py b/sage/modules/vector_callable_symbolic_dense.py
    a b  
    104104            return r"%s \ {\mapsto}\ %s" % (args[0], latex_x)
    105105        else:
    106106            vars = ", ".join(args)
    107             # the weird TeX is to workaround an apparent JsMath bug
    108107            return r"\left( %s \right) \ {\mapsto} \ %s" % (vars, latex_x)
  • sage/symbolic/callable.py

    diff --git a/sage/symbolic/callable.py b/sage/symbolic/callable.py
    a b  
    435435            return r"%s \ {\mapsto}\ %s" % (args[0], latex_x)
    436436        else:
    437437            vars = ", ".join(args)
    438             # the weird TeX is to workaround an apparent JsMath bug
    439438            return r"\left( %s \right) \ {\mapsto} \ %s" % (vars, latex_x)
    440439
    441440    def _call_element_(self, _the_element, *args, **kwds):