-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Syntax to force md parsing inside latex environments #3145
Comments
Just to be clear: when referring to mixed content above I was thinking about environments like a table where text is intermingled with special syntax in a way that is impossible to disentangle by the pandoc reader. I don't have enough experience with complex latex documents to assess the practical relevance of those use cases, though. |
Another option, although tex specific, would be to have a distinguished "tex command", say \md{}, meaning that everything inside it will be parsed. The name might be changed by a command line option to avoid clashes. Since it's tex syntax mixing tex and markdown would be business as usual. |
You're talking about latex environments in markdown +++ memeplex [Oct 05 16 00:46 ]:
|
I'm mainly interested in the markdown reader. Maybe there is some value in
supporting the tex reader also but I'm not able to see how someone that
already embraced tex syntax would be significatively benefited by inlining
small fragments of md.
|
You can try the links in https://github.com/jgm/pandoc/wiki/Pandoc-Filters under "LaTeX related" section. And also the "pandoc-amsthm" link there. I just read a trick in Markdown inside LaTeX code - Google Groups too. |
@ickc are you referring to latexdivs? I know the native div trick but the syntax is clumsy and nesting is very limited. That's why I'm proposing to leverage tex syntax for this (the same than html syntax is used for nesting markdown in html elements). |
Yes. I remember someone opened a respository planning to get markdown in LaTeX syntax in pandoc (I can't find the link now). But it seems he's hitting a brick wall and go back to the idea of using pandoc div and a filter to transform it into LaTeX environment. I remember there are some open issues here concerning the pandoc LaTeX parser (I mean, raw LaTeX in markdown) that has some bugs. In a sense the problem is really how to tell something is raw LaTeX or not. Allowing markdown in LaTeX will further complicate the issue, given it is already not perfect. I'm not saying it is not impossible to have a syntax to force markdown rendering. But I guess such a syntax has to be elegant enough in order to make into the official pandoc. e.g. the official markdown-ish syntax for div and span has already been discussed for more than at least 5 years (just in GitHub issue tracker, not to mention any pandoc discuss before that). So if you are interested in any of the syntaxes you proposed, you'd better wrote a filter and get that working now rather than waiting a few years. I guess the reason that markdown in HTML is much easier to implement is because the HTML syntax (the use of Lastly, I actually don't understand the problem you mention about the shortcoming of the using the pandoc div and how they are intermingled. Can you provide a concrete MWE, using either one of those filters that convert div to LaTeX environments? |
@memeplex, there is a fairly easy LaTeX hack to hide environments from Pandoc. Put this in your LaTeX template or a -H file:
To LaTeX |
- add lines to pass markdown inside latex \Begin{} ~ \End{} - applying jgm/pandoc#3145 (comment)
@bpj This is a clever workaround! Unfortunately, it's not clear to me how to apply it in the case where the |
I think it is just the same, (i.e. `\begin{....`.) Did it fail you?
Yours,
Kolen
…On Jul 3, 2018, 12:37 PM -0700, Carl Boettiger ***@***.***>, wrote:
@bpj This is a clever workaround! Unfortunately, it's not clear to me how to apply it in the case where the \begin takes optional arguments, e.g. \Begin{tcolorbox}[title= Box 1: Machine learning under tipping points, lower separated=false]. Any suggestions?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@ickc thanks, this does create the environment, only the options in the square brackets are not applied to the environment, but instead print literally into the output (i.e. literal |
It happens because Pandoc sees Near the top of the Markdown document or in a header include say: \newcommand\dummy[1]{#1} and then wherever you have an unorthodox command, or in this case \dummy{\Begin{someenv}[optional]} It is important not to create a group inside the definition of the dummy command. |
@bpj Very clever, that works perfectly 🎉 . Many thanks! |
For a little while it seemed like voices couldn't cross section boundaries. It turns out there was a workaround, described in jgm/pandoc#3145, which made it reasonable to undo all of that. This is why the past four commits are reverts.
The extension raw_attribute solves this. (ignore the > ```{=latex}
> \begin{center}
> ```
> Remember to check **Appendix A** for additional resources references and detailed explanations.
> ```{=latex}
> \end{center}
> ``` becomes \begin{note}
Remember to check \textbf{Appendix A} for additional resources references and detailed explanations.
\end{note} |
Raw attribute is the way to go. Closing this. |
Currently latex environments can't include markdown. There is the Begin/End trick and the native div workaround. Both have similar shortcomings: it's not clear how to define an environment with intermixed content (see my next comment). Since it's not possible to write a reentrant filter I'm proposing to add a syntax to force parsing of markdown. The upcoming div syntax could provide the base syntax (inline and block) and be special cased for some specific class, say :::md.
The text was updated successfully, but these errors were encountered: