-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support LaTeX environments in Markdown -> HTML conversion #1938
Comments
|
Actually, surround the |
Oh, and make sure you enable standalone mode |
Very good! This
with
Displays as this in Safari (as mentioned above, labels don't work) |
Ah, the See: mathjax/MathJax#1020 |
It does work as expected with the following changes (@timtylin the bug you mentioned is limited to multi-line labels, and there's workaround for it):
Modified source:
Addition to HTML header:
Pandoc command:
|
Duh. I meant to originally post the following:
since, of course, the |
(I would reopen this but I don't know how to - would it be better to open a new issue with the correct report?) |
I'm not sure why you'd want to reopen it. Wouldn't the method suggested above work for you? |
I think it might be worth preserving the suggestion I made, that raw LaTeX +++ nkalvi [Feb 12 15 14:46 ]:
|
It looks like that's what Pandoc is doing - am I wrong? Here's the output:
Pardon me if I'm not getting it - I'm quite new to Pandoc and LaTex. It'd be helpful if you could post what the desired output is. |
(output is empty) Note: I'm talking about raw latex environments that are not included +++ nkalvi [Feb 12 15 16:21 ]:
|
Thanks for clarifying. |
Ah, I see - that does work (putting stuff in |
|
Yes, but \eqref is a text-mode LaTeX command: it's a reference to an equation number, not a piece of mathematics. :-) |
Aha, you're right. MathJax doesn't require
Now I understand even better jgm's suggestion about passing raw LaTex blocks. |
The problem is actually not solved by So it looks like the only solution is to allow pandoc to pass LaTeX blocks and \eqref{...} etc. to HTML raw when --mathjax is specified. (Perhaps with some other command line parameter to control this behaviour, eg -f markdown+raw_tex?) |
One could easily write a filter which recognises the `.math` class on
codeblocks and codespans and converts the code text to a RawBlock or
RawInline with the right format label and wraps it in the right `<span
class="math">` w/o `<p>` for HTML output.
|
@juliangilbey Could you please give examples of input and output? When I tried some samples with http://johnmacfarlane.net/pandoc/try/ and http://www.tlhiv.org/ltxpreview/ it seems to work fine. Markdown input:
Output from pandoc:
|
The filter I suggested is here: https://gist.github.com/baf84ac52dd47205e5cb Requires perl and some (listed) CPAN modules. |
+++ Julian Gilbey [Feb 13 15 07:58 ]:
There is already an extension for raw tex in the markdown This would be a very easy thing to add. In the mean time, you could write a filter that finds |
Den 2015-02-13 17:09, BPJ skrev:
I did a colossal blooper! Since I don't do math myself I omitted the LaTeX math delimiters https://gist.github.com/bpj/baf84ac52dd47205e5cb#file-pandoc-wrap-raw-pl @jgm wrote:
I think my approach with tagged 'code' may have its use. /bpj |
Hi, I've had a look at the code for this fix and I don't think it's quite right. In order for MathJax to interpret the raw latex you are outputting to HTML, the latex needs to be inside math delimiters. So where you have written
I think it should say
and correspondingly for the inline case. Ideally I think they should also be put inside the appropriate html span as when you write a math block. Sorry if I have misinterpreted you code but I hope what I've said is correct. Ben |
Thanks, this may be correct. This change was mostly intended for things like
which, in LaTeX, would NOT be placed inside math delimiters (
+++ benstevens48 [Mar 02 15 08:45 ]:
|
Yes, I'm pretty sure that MathJax scans the page looking for math delimiters and the processes the stuff inside them, so if it's not inside math delimiters then it will just ignore it. The fact that stuff like the equation environment should not be inside math delimiters in Latex is why we were struggling to get both to work, and hence the use of the filter for the workaround! So, yes, as you said, for mathjax to work, in the html, you write
and
or, to be consistent with pandoc's delimiters for mathjax elsewhere,
I hope this is correct. Ben |
Well, let's confirm that this is correct before continuing, since in LaTeX it wouldn't be correct to do things this way... +++ benstevens48 [Mar 02 15 10:53 ]:
|
Hi, |
@juliangilbey This issue has come up before, multiple times. Early last year I ran in to it and got pretty much the same response regarding a filter and such. The result was similar to yours... 😞 So to scratch my itch a patch was submitted that didn't alter the behavior of any of the targets except latex (since the latex target is where the problem exists) without any side-effects. If you don't mind patching yourself, I've been using it over a year now with great results. Essentially all it does is strip the [update] |
+1 for PR |
@Thell I'd also like to see this pulled into pandoc proper |
@mseri and @diazona we'll need to see what @jgm wants. There are currently quite a few outstanding issues and pull requests and the latest release does at least allow passage of raw blocks (which helps with html/latex targets) so I'm guessing it will be a while unless we can come up with a non edge-case usage example. |
This provides a workaround for jgm/pandoc#1938
With Pandoc 2.2, I'm still having this issue. Naked math latex environments do not make it to the html from pandoc. Note that in order to be processed by mathjax properly, the equation, align, ... environments would need to be wrapped in
Any further advice on how to produce proper html and latex from the same markdown? How should one markdown equations to support both outputs? |
@rreece - please give a specific example of a math environment that isn't properly (full instructions for how to reproduce the issue). And probably better to open a new issue, referring to this one, since this one is closed. |
The following piece of LaTeX-enriched markdown:
converts beautifully to LaTeX with
pandoc -f markdown -t latex
. However, when converting to html5, even with the--mathjax
option, I can't figure out any way to persuade pandoc to maintain the aligned environment or the\eqref
, despite the fact that MathJax can handle these.Any suggestions?
Thanks!
The text was updated successfully, but these errors were encountered: