You might find mimeTeX useful.
yes, but you'll have to hack it a little yourself. I've written a filter that replaces latex tags $\some\inline\latex$
or $$\some\equation$$
with appropriate image tags to a mimetex.cgi script. It took all of 5 minutes.
Warning: spectacularly ugly...
#!/usr/bin/env python
import sys, markdown,re
MIMETEX_LOC="http://some.server.com/cgi-bin/mimetex.cgi"
def sanitizeLatex(text):
return re.sub(r"\\",r"%5C", text)
def wrapLatexBlock(text):
return '<img alt="equation" class="block" src="%s?%s"></img>'%(MIMETEX_LOC,text)
def wrapLatexInline(text):
return '<img alt="equation" class="inline" src="%s?%s"></img>'%(MIMETEX_LOC,text)
def prepLatexBlock(matchobj):
return wrapLatexBlock(sanitizeLatex(matchobj.group()[2:-2]))
def prepLatexInline(matchobj):
return wrapLatexInline(sanitizeLatex(matchobj.group()[1:-1]))
if __name__ == "__main__":
# initialise markdown
md=markdown.Markdown()
raw_md=open(sys.argv[1],"r").read()
##
# deal with embedded latex
##
raw_md=re.sub(r'\$\$(.*?)\$\$',prepLatexBlock, raw_md)
raw_md=re.sub(r'\$(.*?)\$',prepLatexInline, raw_md)
##
# once latex is parsed, convert md to html
##
main_html=md.convert(raw_md)
# hey presto!
print(main_html)
Of course, you have to define the appropriate css yourself for .block and .inline images...
I'll answer your question with a counter-question...
What do you think of Org-mode? It's not as pure as Markdown, but it is Markdown-like, and I find it as easy to work with, and it allows embedding of Latex. Cf. http://www.gnu.org/software/emacs/manual/html_node/org/Embedded-LaTeX.html
Postscript
In case you haven't looked at org-mode, it has one great strength as a general purpose "natural markup language" over Markdown, namely its treatment of tables. The source:
| 1 | 0 | 0 | | -1 | 1 | 0 | | -1 | -1 | 1 |
represents just what you think it will...
And the Latex is rendered in pieces using tex-mode's preview-latex.
you should look at multimarkdown http://fletcherpenney.net/multimarkdown/
it has support for metadata (headers, keywords, date, author, etc), tables, asciimath, mathml, hell i'm sure you could stick latex math code right in there. it's basically an extension to markdown to add all these other very useful features. It uses XSLT, so you can easily whip up your own LaTeX styles, and have it directly convert. I use it all the time, and I like it a lot.
I wish the markdown would just incorporate multimarkdown. it would be rather nice.
Edit: Multimarkdown will produce html, latex, and a few other formats. html can come with a style sheet of your choice. it will convert into MathML as well, which displays in Firefox and Safari/Chrome, if I remember correctly.
And if you will excuse a second flawed answer to your question, this depending on answering another unsolved problem or two...
My question, Convert Tex to Metapost, is concerned with rendering, and if I had a good answer to that, it should be possible to put together a good solution to your question, Metapost having all the abilities to hack bounding boxes you could want, and having your choice of lovely rendering engines, through .eps, SVG, &c.
Maybe it would be possible to make a drop-in replacement/extension to dvipng that is based on SVG? It might be possible to use SVG + HTML technology to present SVG where the browser has that, and have an ALT-tag that presents a PNG if it is not there.
What language are you using?
If you can use ruby, then maruku can be configured to process maths using various latex->MathML converters. Instiki uses this. It's also possible to extend PHPMarkdown to use itex2MML as well to convert maths. Basically, you insert extra steps in the Markdown engine at the appropriate points.
So with ruby and PHP, this is done. I guess these solutions could also be adapted to other languages - I've gotten the itex2MML extension to produce perl bindings as well.