MattFlower / organized

Outlining, scheduling, and todos inside of the Atom Editor
MIT License
114 stars 19 forks source link

LaTeX formula support? #24

Open nsaphra opened 6 years ago

nsaphra commented 6 years ago

Any plans to support inline LaTeX compilation? Otherwise, any guidance on how one might go about implementing it?

MattFlower commented 6 years ago

This would depend a bit on what you mean.

If you are talking about about code blocks having LaTeX support, that would be pretty easy to do and I’d be happy to give you some guidance on how to make the change in organized to support it.

If you are talking about LaTeX export, that’s going to have to wait a bit. I have plans to allow exporting to HTML and maybe PDF at some undetermined point in the future. Getting there is going to require some design work and refactoring on my part to avoid something that’s impossible to maintain. My work on Organized is adhoc, uneven, and mostly done on a train, so no guarantees when that will happen.

nsaphra commented 6 years ago

I would love to have some guidance on how to make that change. It would be really useful to me to have the code blocks with LaTeX.

On Oct 26, 2017, 2:07 PM +0100, Matt Flower notifications@github.com, wrote:

This would depend a bit on what you mean. If you are talking about about code blocks having LaTeX support, that would be pretty easy to do and I’d be happy to give you some guidance on how to make the change in organized to support it. If you are talking about LaTeX export, that’s going to have to wait a bit. I have plans to allow exporting to HTML and maybe PDF at some undetermined point in the future. Getting there is going to require some design work and refactoring on my part to avoid something that’s impossible to maintain. My work on Organized is adhoc, uneven, and mostly done on a train, so no guarantees when that will happen. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

MattFlower commented 6 years ago

Sure, I'd be happy to accept a PR on this.

Organized relies on other plugins for highlighting support. For example in Java, it relies on https://github.com/atom/language-java to do the highlighting. To make highlighting work in organized, we need to instruct organized/atom to know that the code inside a code block is actually LaTeX code. This amounts to mapping the latex part of

```latex


To something that knows the grammar of LaTeX.  To do that, modify organized.cson and copy one of the existing blocks that does this.  For example, "java.code.block.organized".  Choose a string to identify LaTeX code (latex sounds good to me) and search/replace.

The tricky part here is the part that says "source.java".  That refers to the scope name for a plugin that understands the grammar of the language you are adding.  You'll need to figure out what the scope name of your plugin is.  If you happened to use [this plugin](https://github.com/area/language-latex), you'd find the scope name in one of [these files](https://github.com/area/language-latex/tree/master/grammars).  I'm going to guess you want the scope "text.tex.latex" from latex.cson, but you are the expert here - I haven't touched TeX since years started with the number 19.  

You could conceivably add the ability to execute LaTeX code blocks as well.  If you are interested in that, you'd need to change codeblock.coffee.  The changes would be as follows:

1. If LaTeX really cares what the extensions are on files (some compilers or interpreters do), modify the execute method to put an extension on there.
2. Modify the executionEngine method to support LaTeX.  More than likely, you'll be like every other language and you'll just be a one liner.  

Good luck -- it would be fantastic to see a PR on this.
clsmt commented 6 years ago

Maybe use mathjax to do in-line rendering? Similar to what they've done with markdown preview plus. It's really neat.