Skip to content
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

Added a filter to turn pandoc native divs into latex environments #40

Merged
merged 6 commits into from
Oct 2, 2016
Merged

Added a filter to turn pandoc native divs into latex environments #40

merged 6 commits into from
Oct 2, 2016

Conversation

ickc
Copy link
Collaborator

@ickc ickc commented Apr 21, 2016

No description provided.

@ickc
Copy link
Collaborator Author

ickc commented Apr 21, 2016

I also added a filter to turn any divs with latex="true" into a latex environment by the first class.

Description:

Pandoc filter to convert divs with latex="true" to LaTeX
environments in LaTeX output. The first class
will be regarded as the name of the latex environment
e.g.
<div latex="true" class="theorem abc">...</div>
will becomes
\begin{theorem}...\end{theorem}

@ickc ickc changed the title Added 12 others amsthm environments; and a script to auto generate any others Added a filter to turn pandoc native divs into latex environments Apr 22, 2016
@ickc ickc closed this Apr 22, 2016
@ickc
Copy link
Collaborator Author

ickc commented Apr 22, 2016

Sorry, wrong click!

@ickc ickc reopened this Apr 22, 2016
@chdemko
Copy link
Contributor

chdemko commented Apr 22, 2016

You can also have a look to https://github.com/chdemko/pandoc-latex-environment

@ickc
Copy link
Collaborator Author

ickc commented Apr 22, 2016

Looks great! I hope either one of these can make into the official pandoc language.

If there's no hope of making any of these into the official pandoc language, I probably would folk yours and apply it in the amsthm environments I made at ickc/pandoc-amsthm: provide amsthm environments in pandoc with valid output in LaTeX and HTML which also uses YAML front matter to define some environments.

@chdemko
Copy link
Contributor

chdemko commented Apr 22, 2016

I've also implemented a kind of automatic numbering filter similar to theorem-like environment https://pypi.python.org/pypi/pandoc-numbering/

@ickc
Copy link
Collaborator Author

ickc commented Apr 22, 2016

Wow. Very interesting. Yours is very sophiticated and ganranteed to work in all output formats. The only downside is that it isn't using LaTeX's amsthm in LaTeX output (but it's like an amsthm package for pandoc). By the way, have you tested how different the LaTeX output will be from using amsthm to do it, in terms of both numbering and visually (typographically)?

@jgm

His syntaxes and the way it works has a pandoc feel. May be it should make into the offcial pandoc syntax? (or an official pandoc filter that is recommended by the documentation?) I noticed that there are other filters here and there related to numberings (e.g. equation numbering) and references by the numbering. It would be great if they can be integrated together under a big packages/documentclass (the filters in pandoc are like the packages in latex, but may be we need something like a memoir or amsart "documentclass" (just a bigger filter) that ties all these filters together in a harmonize way.

As I was brain-storming, may be pandoc need something like a CTAN and TeX Live so that those filters can be centralized (in a sense this repository could be that thing, but obviously it isn't centralized enough). e.g. if there's a way to install "official" pandoc filters in this repository from the command line pandoc install.... Along the same line, templates could also be allowed to install this way (like a sty).

@chdemko
Copy link
Contributor

chdemko commented Apr 22, 2016

There is a wiki page for all third-party filters: https://github.com/jgm/pandoc/wiki/Pandoc-Filters

@ickc
Copy link
Collaborator Author

ickc commented Apr 22, 2016

I knew that but it is not exhaustive, lacking the ecosystem for an incentive to put it there (e.g. should I push to this repo or edit the wiki over there?), and it's description is not good for filter discovery (e.g. as you mention it, I bet yours is also there, but a quick glimpse cannot find it. I once opened all links there and hasn't "discovered" your excellent filter. Probably it isn't obvious about what the fitlers are doing).

And not to mention if there's a centralized thing like TeX Live or brew, all installed filters can be updated at once.

But as I said I was brainstorming and probably dreaming because it certainly takes a lot of effort and resources to do something like that. And in the TeX world it isn't exactly easy to discover and pick packages either.

@ickc
Copy link
Collaborator Author

ickc commented Apr 22, 2016

I just clean up the wikis over there. There's a lot of room to improve though. All those numbering filters are confusing and probably a table needed to be created.

@ickc
Copy link
Collaborator Author

ickc commented Apr 23, 2016

@chdemko I do exactly like I said and forked your filter to incorporate it with my ickc/pandoc-amsthm: provide a syntax to use amsthm environments in pandoc, with output in LaTeX and HTML. Thanks for pointing me to your filter.

@ickc
Copy link
Collaborator Author

ickc commented Oct 2, 2016

@jgm Will this example be considered to add? If not, please close it. Thanks!

@jgm
Copy link
Owner

jgm commented Oct 2, 2016

This all looks fine to me, and will be useful to some people.
I never intended the examples directory to be an actual repository of useful code -- ideally, as you say, there should be another central place for such things. But I don't have a problem merging.

@jgm jgm merged commit 35ea1a7 into jgm:master Oct 2, 2016
@ickc
Copy link
Collaborator Author

ickc commented Oct 2, 2016

ideally, as you say, there should be another central place for such things

By the way, I have an idea that we can use brew as a package manager for pandoc-filters. Since pandoc filters are not written solely in a certain language, many package managers are out of questions. But brew is very generic. And there's also a linux port of it. So it could serves the Mac/Linux at the same time.

The same concept could apply to pandoc templates too. But that might be more problematic by the nature of it: templates usually are too specific. I am asking in jgm/pandoc#3138 about using template in header-includes. If the idea works (there's already work-around mentioned), we can make custom templates modular. And modular templates will be much more useful if managed by a package manager.

@sergiocorreia
Copy link
Contributor

sergiocorreia commented Oct 2, 2016

@ickc , I would also love some sort of package manager, although Windows support would be quite valuable.

BTW, Pandoc 1.17.3 now "checks $DATADIR/filters for filters before looking in the path", so a simple pacman would just sync filters in that folder against an external repo (easier said than done of course).

@ickc
Copy link
Collaborator Author

ickc commented Oct 2, 2016

May be this should be discussed in pandoc-discuss further and see if others are also interested in the idea?

Regarding Windows support, recently there's WSL (Windows Subsystem for Linux) that gives us Bash on Ubuntu on Windows. Windows 10 Anniversary update only (optional beta feature that requires user activation). I didn't have time to play with it in details. But I think probably it can turn a Windows machine to be "Unix-like" in many situations. If pandoc and linuxbrew works on it, using brew would means support on Mac/Linux/Windows 10 Anniversary.

The brew I think that is more suitable probably is brew cask, it install binaries rather than from source code. cask-fonts can install fonts to the font directory instead. i.e. we can install filters in ~/.pandoc/filters, then templates in ~/.pandoc/templates, etc. Another nice feature of brew is it will compute sha-256 hash to check the integrity of the downloaded files. Since pandoc filters are executables, it can potentially be dangerous.

No experience on pacman though. Do you think it would be easier to setup, and support more platform?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants