-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add exporting to latex template #80
Conversation
Thanks for the contribution👍 |
Hi @mokeyish this is still a draft. Need to do a bit more work |
Hi @mokeyish , I am currently waiting on pandoc to see how to use relative paths as it seems that resource-path is not being used for Have tried a lot but don't seem to be able to export. Essentially if you use iCloud, your files are placed in a folder with a space in its name. Latex does not like spaces. Even when trying to sanitise the path, both in latex and javascript, I still had issues. The current workaround is to pass the path to the template in the metadata and make sure there are no spaces:
So far I've built two templates. Here are some sample documents Generated from this Regarding your points. I updated the UI to this: Initially I thought it would be best to have the export templates in export_command_templates as you mentioned. But I realised after showing it to people that it was not intuitive. People seem to see "Type" as the file format and it is not intuitive to scroll through all the extensions to then find the correct pdf. So I ended up creating a conditional element in the UI. If the format can take the template, then you see the above image. Else: ![]() Let me know your thoughts. Also I don't think I will be able to work on this much more. Once I find a fix for the template problem I will push it though not sure when. |
|
|
@mokeyish I found a workaround using TEXINPUTS. TEXINPUTS is a variable for setting additional style paths (which is what we need to do here. On terminal I modified my .zshrc with this:
Ideally we just need to use this variable rather than the path ${textemplateDir} Is this something we can help with? I really need some help here because I don't know JavaScript / Apps set this environment variables... |
You can set environment variables with following code. (Maybe should make it configurable in the Settings Tab) await exec('commands', { env: 'TEXINPUTS': 'path/to/textemplate'}) obsidian-enhancing-export/src/utils.ts Line 24 in 8345d24
|
It seems that my English is really poor, I can't explain my meaning correctly😂. |
Is there a way to access ${textemplateDir} in from that file? Also how do we add TEXINPUTS can contain many paths. |
You should pass your obsidian-enhancing-export/src/exporto0o.ts Line 171 in 8345d24
The concatination of multiple textemplateDirs are different on different platform(unix: join paths with |
Sorry I'm not sure I follow. This is the command we want:
If you don't mind, could commit the change and I can test it? I'm going crazy working with typescript and doing the template took a really long time... |
Just like this: TEXINPUTS = joinEnvPath(textemplateDir, orignal_TEXINPUTS) obsidian-enhancing-export/src/utils.ts Lines 53 to 60 in f0ce1d0
|
Saw your email, don't worry. Please rewrite following code: obsidian-enhancing-export/src/exporto0o.ts Line 171 in f0ce1d0
as: // orginal `$TEXINPUTS` should be empty, so ignore it.
await exec(cmd, { cwd: variables.currentDir, env: { TEXINPUTS: joinEnvPath('path/to/texttemplates/', './') } }); |
Hey @mokeyish I think we are close! I changed the variable to this: await exec(cmd, { cwd: variables.currentDir, env: { TEXINPUTS: joinEnvPath(`${textemplateDir}`, `${process.env.TEXINPUTS}`) } }); Without the previous TEXINPUTS, latex throws errors like The problem at the moment is that it says "Success!" and no file is produced. Do you know what could be happening? |
Are you sure it's an environment variable issue? Obsidian's environment variables are only the most basic, and we have to see what is missing and add the rest. just like obsidian-enhancing-export/src/main.ts Lines 32 to 39 in f0ce1d0
|
I'm on windows and can't test latex. Let's do this for now, and optimize it slowly later. |
Nice, is this good to be merged then? |
It cannot be merged yet, latex templates are currently hard-coded. We should make it configurable. |
Sorry I thought I fixed the conflicts on merge... give me a minute. |
Ok I can add your changes but as I mentioned before the app does not work. It loads forever when exporting. |
@universvm Hi Leo, |
@mokeyish see the code now. I did what you said but the plugin does not work. Unfortunately I cannot work on this anymore. If you can fix the bug feel free to merge. If not close this issue and I will publish my templates somewhere else. |
I also don't really want to spend time on this project 😂. I wrote this project because I couldn't find a suitable tool for sharing notes and wanted to export it to the hugo blog, so I spent a few days writing such a plugin. If you don't want to continue to toss. You can put the final |
@mokeyish Addressed all the changes you had made + fixed a small bug. The templates will be published in here: https://github.com/universvm/academic-pandoc-templates I will keep this plugin updated with the templates. The repository above contains tutorials on how to use the templates etc.. |
Let's close this PR, and could you resubmit a new one base on the branch https://github.com/mokeyish/obsidian-enhancing-export/tree/dev ? please use |
// show progress | ||
progress.setMessage(lang.preparing(outputFileFullName)); | ||
beforeExport && beforeExport(); | ||
progress.show(); | ||
|
||
const pandocPath = getPlatformValue(globalSetting.pandocPath) ?? 'pandoc'; | ||
|
||
const cmdTpl = | ||
let cmdTpl = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are unnecessary. The template render function will do this automatically. Do you understand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole changes of this file are also unnecessary.
Hi @mokeyish Could you have a look now? I reverted the changes you mentioned and tested. If all is good I will clean up the commit history. If not let me know I can change |
@mokeyish I am having problems with conflicts squashing the commits. Can we squash everything into one when merging to dev? |
No need to resolve conflicts. create a new branch to applly your changes. |
Ah ok! Will probably do these tomorrow :) |
Closes #66 .