TandoorRecipes / recipes

Application for managing recipes, planning meals, building shopping lists and much much more!
https://docs.tandoor.dev
Other
5.37k stars 571 forks source link

Latex Export #1544

Open vabene1111 opened 2 years ago

vabene1111 commented 2 years ago

Discussed in https://github.com/TandoorRecipes/recipes/discussions/1462

Originally posted by **supaeasy** February 1, 2022 Hello there I just stumbled across this marvellous project (thank you [heise.de](https://www.heise.de/ratgeber/Open-Source-Software-Tandoor-Recipes-Rezeptdatenbank-einfach-selbst-hosten-6319271.html)) and it looks like everything I ever wanted in a recipe database. While I love the Idea of having a flexible database with scaling, shopping list and whatnot I also heavily rely on printed recipes in a decent look. Right now I am using a fiddly, fiddly workflow of storing recipes in Paprika App, exporting them to json and parsing them in Airtable to LaTeX via Overleaf. While this does get me the beatuiful end result I want (see example attached), this is nowhere near convenient and I see this project as a real opportunity for a single-step-export solution. I will be happy to share my parsing method from json to LaTeX but am no real programmer myself and don't know how to implement this as an export function to Tandoor Recipes. Is this something you could do? It would however require TR to comply with schema.org's [Recipe Standard](https://schema.org/Recipe) for a quick start. If it does not comply, I would still offer to rewrite my method to TR's system if an export to LaTeX function would be considered. [Kochbuch_xcookybooky (1).pdf](https://github.com/TandoorRecipes/recipes/files/7978561/Kochbuch_xcookybooky.1.pdf)
vabene1111 commented 2 years ago

ok @supaeasy i think we have moved to the stage where this is sophisticated enough to transfer it to its own issue.

I get the basics of your setup but it is rather complicated and it is very custom tailored to your recipe database/preferences. I think in order for this to make sense there needs to be one .tex file per recipe or maybe even one large one so that someone using this who has a basic understanding of latex can use it (i myself would say i am somewhat familar with latex but dont understand how your files work).

We need to create that template and a more or less standard capable solution that can work for everyone. In the end we will likely make this some kind of templating solution anyway so if you want to change it back to your latex template after we created the upstream implementation you can still easily do this by forking of if i create a second variant of the exporter.

supaeasy commented 2 years ago

So the base of what I was working with is the xkookybooky Package. It is both possible to include all the single tex recipes in one file as in the packages example or to have them one by one which I prefer personally.

I have imported a recipe from my Paprika base to your demo. (Didn't work very flawlessly as some Ingredients weren't recognised but I edited it to be correct.) in ID 6610 I tried out steps.

On a first glance the export file from tandoor looks a LOT easier to work with than what I was used to from Paprika. 2/3 of the work was finding things correctly and your output is very neat and clean. If you want me to, I can adapt my substitutor to this if it helps, but I guess you should find it very easy to do so now. It really is just very important to stick to strict rules when entering the recipe, such as entering every step on it's own or stick to my -Schritt 1-, etc. spelling rule . One thing that will not work is to handle per-step ingrediences as there just is no concept for that in xcookybooky.

Let me know if you need anything. I have also included my custom cfg (remove txt extension) in case that raised any questions. I don't remember to what extend I have customized it, it has been some time since I last worked on this.

xcookybooky.cfg.txt

vabene1111 commented 2 years ago

thanks for the research. I am not sure if i have missed this in any of the previous posts but i am still missing a "tempalte" text file. Maybe i just think wrong but i would expect something like this

% all the packages

\begin{document}
..
<INSERT RECIPE NAME HERE>
...
<INSERT INGREDIENTS HERE>

...
..
\end{document}

if i have something like that its easy to just dump out a whole bunch or one single tex file

supaeasy commented 2 years ago

That is in the file "Ausgabe in TeX.txt" from the discussion section. Look into my last reply.

vabene1111 commented 2 years ago

thanks, but that doesn't really cut it. To be honest the latex exporter wont be used by many peopel (if any besides you) so i need to keep the amount of work to a somewhat acceptable level. The file you provided is minified and in a strange format i dont know, i have also no idea where to place my data into that file.

Only with understanding the structure and formatting it so that i can somewhat read and understand it would take me hours which i then would not have to work on very important topics like the new importer and so on.

I need

sorry for being so picky but building and figuring all this stuff out would take me days and i currently am happy when i have a few hours to work on the most important issues.

supaeasy commented 2 years ago

No problem, i will provide a commented file.

m42e commented 2 years ago

Can't we generalise it in a way, that it is a "templated export"? User defined template, using markers and then generate the text using maybe jinja?

vabene1111 commented 2 years ago

thats likely possible, probably also how i would implement latex. But i think i would keep it on a PR basis, people can write templates, make a PR and i will add that to tandoor, at least at first.

supaeasy commented 2 years ago

Sorry btw that I didnt deliver the file yet but I am too busy at the moment. Will provide it eventually but I dont know when yet.

vabene1111 commented 2 years ago

no worries, we all have a lot on our plates, things come when they are ready. But @m42e idea is good, if we have an example template file other people can easily adapt it.

supaeasy commented 2 weeks ago

After some "busy moments" of over two years I am finally able to start over with this topic. I think I will simply write something in python that converts an export of any recipe to a latex file in a mannered and commented structure. Ist that fine for further implementation or should I start with a different initial approach to make implementation easier for you?

vabene1111 commented 2 weeks ago

sounds good to me! just take a recipe export, load it into python in an object called recipe and print out the latex.

You could look into using jina for templating, not sure if that makes sense or if just plain old string concats are the best.

Once you are done post the latex here and I will either implement it myself or build the surrounding structurue for you to implement it into

supaeasy commented 1 week ago

Thank you for suggesting jinja to me. I wasn't aware this existed. Learning this has been an eyeopening experience for me. I am already very far and have a 99% working example that generates a .tex file, I only have to fix minor things now. Will probably post results in the next few days. I use an API call so there is no need for an export first. The only thing I cannot deliver is the actual LaTeX implementation/pdf creation. Is this something you could do? This will be single recipe export first. Later I will maybe provide support for cooking books.

vabene1111 commented 1 week ago

The latex implementation should just be any normal Tex engine right? Since you got it working trough the API I suggest you just create a small GitHub repo for it that you link here. I can then at some point implement it directly into tandoor (with your permission)

supaeasy commented 1 week ago

Here you go, I hope you like it: https://github.com/supaeasy/Tandoor2xcookybooky. You have my permission to integrate it wherever you want.