GithubHelp home page GithubHelp logo

imclab / php-markdown-extra-math Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drdrang/php-markdown-extra-math

0.0 2.0 0.0 1.46 MB

PHP Markdown Extra with support for jsMath

Home Page: http://www.leancrew.com/all-this/2010/09/php-markdown-extra-math-mathjax-and-wordpress/

License: Other

php-markdown-extra-math's Introduction

PHP Markdown Extra Math is an extension of Michel Fortin's PHP Markdown Extra, a PHP script for converting text written in Markdown to HTML. The extension consist of adding support for mathematical equations written in LaTeX to be processed by either the MathJax (default) or jsMath math rendering libraries.

Use

Here's how it works. The author, writing in Markdown, inserts inline equations like this

where \(\alpha = (t_1 - t_0)/L\) is the rate at which the thickness increases

enclosing the math in a \( … \) pair, just as if writing in LaTeX. PHP Markdown Extra Math converts that to

where <span class="MathJax_Preview">[math]</span><script type="math/tex"> \alpha = (t_1 - t_0)/L </script> is the rate at which the thickness increases

for MathJax, or

where <span class="math"> \alpha = (t_1 - t_0)/L </span> is the rate at which the thickness increases

for jsMath. This is then converted by whichever math rendering library is being used to

inline math example

(The example is shown as an image but will be rendered as selectable and scalable text if the server has MathJax or jsMath installed.)

Similarly, display Math is enclosed in \[ … \] like this:

Putting this into Castigliano's equation, we get

\[\Delta = \frac{\partial U^*}{\partial F} = \frac{12F}{Eb} \int_0^L \frac{x^2}{(t_0 + \alpha x)^3} dx\]

which PHP Markdown Extra Math will turn into this HTML

<p>Putting this into the Castigliano equation, we get</p>

<span class="MathJax_Preview">[math]</span><script type="math/tex; mode=display">\Delta = \frac{\partial U^*}{\partial F} = \frac{12F}{Eb} \int_0^L \frac{x^2}{(t_0 + \alpha x)^3} dx</script>

for MathJax, or

<p>Putting this into the Castigliano equation, we get</p>

<div class="math">\Delta = \frac{\partial U^*}{\partial F} = \frac{12F}{Eb} \int_0^L \frac{x^2}{(t_0 + \alpha x)^3} dx</div>

for jsMath. This will be rendered as:

display math example

Configuration

The choice of MathJax or jsMath output is made on Line 42 of markdown.php:

@define( 'MARKDOWN_MATH_TYPE',      "mathjax" );

Change the "mathjax" to "jsmath" to change the rendering library.

A MathJax detail

The <span class="MathJax_Preview">[…]</span> that precedes the MathJax code serves three purposes:

  1. It's a placeholder that's displayed briefly while the equations are rendered.
  2. It eliminates a rendering problem associated with Internet Explorer 8.
  3. It gives Instapaper users a sense of what the rendered equation would be (if they understand LaTeX).

License

PHP Markdown Extra Math is licensed under the same terms as PHP Markdown Extra. See the License.text file.

php-markdown-extra-math's People

Contributors

drdrang avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.