cebe / markdown

A super fast, highly extensible markdown parser for PHP

Home Page:http://markdown.cebe.cc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to replace $x<y$ with $x < y$

fardina opened this issue · comments

I am using cebe markdown in my website for writing mathematics.
If I use less than sign it causes some problems in rendering mathjax, see here: http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents

How can I search all the text for less than sign like "x<y" and replace it by "x < y"?

Thank you for your help

how is that question related to this library? do you have a parsing method that handles your math syntax?

Do this right before passing your text to markdown library:

$text = preg_replace('~([a-z0-9]+)([<>=+-])([a-z0-9]+)~', '\1 \2 \3', $text);