Closed thriveth closed 5 years ago
It is very good idea to extend the capabilities of it by supplying option ( may be easy to do but I don't know ruby to try). For example, MultiMarkDown supports LaTeX which I use it heavily
So, I'm already working on adding pandoc support at my node.js-rewrite branch at https://github.com/suan/instant-markdown-d/tree/pura-noda
Question though, how is LaTeX typically used with pandoc markdown? Is a HTML file generated with the relevant TeX portions already converted to HTML/CSS, or is a .tex file generated? If it's a .tex file, can browsers even open those? Even if it's a PDF, it will be tricky to auto-update because instant-markdown-d relies on embedded javascript to refresh the page...
There are several different ways for pandoc to handle LaTeX. One simple
(but less elegant) method is the --webtex
option, which uses a
web/based rendering engine to render the code into .png images which
are then inserted into the HTML file.
Another option is using MathJax, which is by far the most elegant and best/looking solution. I am not sure how it works, but one way to find out is of course to try a simple example, convert it using MathJax, and then take a look at the output .html file. Possibly I can take a little look at that tonight, if work is quiet.
On Sun 02 Mar 2014 05:10:10 PM WET, suan wrote:
So, I'm already working on adding pandoc support at my node.js-rewrite branch at https://github.com/suan/instant-markdown-d/tree/pura-noda
Question though, how is LaTeX typically used with pandoc markdown? Is a HTML file generated with the relevant TeX portions already converted to HTML/CSS, or is a .tex file generated? If it's a .tex file, can browsers even open those? Even if it's a PDF, it will be tricky to auto-update because instant-markdown-d relies on embedded javascript to refresh the page...
— Reply to this email directly or view it on GitHub https://github.com/suan/vim-instant-markdown/issues/48#issuecomment-36459502.
Ok, I tried a simple example with MathJax now. Here is the input:
A test document
==============================================================================
# A H1 Headline {sec:H1}
bla bla bla
And here is some math:
$$
\nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0}
\nabla \cdot \mathbf{B} = 0
\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}
\nabla \times \mathbf{B} = \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t}
$$
Running the following command:
pandoc -sS test.mkd --mathjax -t html -o test.html
Gives the following output:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
</head>
<body>
<h1 id="a-test-document">A test document</h1>
<h1 id="a-h1-headline-sech1">A H1 Headline {sec:H1}</h1>
<p>bla bla bla</p>
<p>And here is some math:</p>
<p><span class="math">\[
\nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0}
\nabla \cdot \mathbf{B} = 0
\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}
\nabla \times \mathbf{B} = \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t}
\]</span></p>
</body>
</html>
Setting the --webtex
flag instead of --mathjax
yileds this output:
\<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="generator" content="pandoc" />
<title></title>
<style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<h1 id="a-test-document">A test document</h1>
<h1 id="a-h1-headline-sech1">A H1 Headline {sec:H1}</h1>
<p>bla bla bla</p>
<p>And here is some math:</p>
<p><br /><img style="vertical-align:middle" src="http://chart.apis.google.com/chart?cht=tx&chl=%0A%5Cnabla%20%5Ccdot%20%5Cmathbf%7BE%7D%20%3D%20%5Cfrac%7B%5Crho%7D%7B%5Cepsilon_0%7D%0A%5Cnabla%20%5Ccdot%20%5Cmathbf%7BB%7D%20%3D%200%0A%5Cnabla%20%5Ctimes%20%5Cmathbf%7BE%7D%20%3D%20-%20%5Cfrac%7B%5Cpartial%20%5Cmathbf%7BB%7D%7D%7B%5Cpartial%20t%7D%0A%5Cnabla%20%5Ctimes%20%5Cmathbf%7BB%7D%20%3D%20%5Cmu_0%20%5Cmathbf%7BJ%7D%20%2B%20%5Cmu_0%20%5Cepsilon_0%20%5Cfrac%7B%5Cpartial%20%5Cmathbf%7BE%7D%7D%7B%5Cpartial%20t%7D%0A" alt="
\nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0}
\nabla \cdot \mathbf{B} = 0
\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}
\nabla \times \mathbf{B} = \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t}
" title="
\nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0}
\nabla \cdot \mathbf{B} = 0
\nabla \times \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}
\nabla \times \mathbf{B} = \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t}
" /><br /></p>
</body>
</html>
Thanks for looking into that @thriveth. I think I have an idea of how to implement it now - opening a .tex
file will behave similarly to opening a markdown file - a live-updating browser window will open with the compilation done using Mathjax.
@suan Sorry to brother but I still can't write scientific text such as $x^2$
Now it supports mathjax in #145 and suan/instant-markdown-d#53. For pandoc, there is a dedicated vim plugin, see https://github.com/vim-pandoc/vim-pandoc
Hi @ashwinvis --
The Pandoc plugin you link - vim-pandoc - is not a previewer, but an aid to write and edit Pandoc's Makdown flavor.
This feature request was about adding the capability to preview Pandoc's Markdown flavor to vim-instant-markdown. This functionality is not and will not be covered by vim-pandoc.
You are right, but does mathjax work for you, or you need pandoc specific stuff? If it is the latter, I will reopen the issue.
Your minimal example is covered by mathjax. Also let me add that with vim-pandoc
, you do get a :Pandoc
command which is not "instant" but works pretty well to preview render. Just keep a PDF viewer open instead of the browser :)
I write quite a lot of scientific text, and Pandoc with its extended MarkDown has excellent support for some features that ordinary MarkDown oor GitHub-flavored MarkDown doesnẗ. On the other hand, I believe pandoc has support for most, if not all, GH flavored extensions. So maybe it would be great with an option to use Pandoc as the converting backend if it is installed on the user's system?