obsidian-enhancing-export icon indicating copy to clipboard operation
obsidian-enhancing-export copied to clipboard

Ignore status code when exporting to PDF

Open kchousos opened this issue 1 year ago • 6 comments

Hello!

First of all, thank you for your awesome plugin. I wanted to ask if it is possible for the plugin to ignore the export command's status code and finish running it. When running manually the commands, even though latex gives errors, the PDF is generated as desired. It would be very convenient to be able to generate the PDF directly through the plugin, instead of generating the latex code and then compiling manually. Thanks in advance.

kchousos avatar Dec 14 '23 18:12 kchousos

When running manually the commands, even though latex gives errors, the PDF is generated as desired.

You can definitely achieve this. You just need to add a line to your defaults file (for example defalts-pdf.yaml) for pandoc and use it to compile the PDF.

How to do it?

  1. Create a yaml file filename.yaml in a convenient location.
  2. Inside the yaml add the line fail-if-warnings: false.
  3. In the Obsidian app go to Export Settings > Edit Command Templates > Choose template and select the PDF option.
  4. In the Extra arguments add this --defaults='path-to-file/filename'. Do make sure to leave a space if there are any other code written in this field.
  5. Now you can run the export command as you like and it will export like LaTeX ignoring the warnings. (Not Fatal errors only warnings, I don't remember any LaTeX compiler passing fatal errors.)

OR

Directly skip to step 3 and in step 4 go to the Arguments and add --fail-if-warnings=false

TheFermi0n avatar Dec 15 '23 14:12 TheFermi0n

@TheFermi0n Thanks for your answer. I'm not as familiar with pandoc as you are. I just made the wiki open for anyone to edit. are you willing to put this on the wiki? I think this is better than a piecemeal answer on the issue.

mokeyish avatar Dec 15 '23 14:12 mokeyish

@TheFermi0n Thank you for your answer. Unfortunately, this does not work. Turns out that my initial statement is false:

When running manually the commands, even though latex gives errors, the PDF is generated as desired

This is true if I export to LaTeX and then compile it manually, but exporting to PDF fails at the command line too. The fail-if-warnings option doesn't change it.

The output I get when I try to export directly to PDF is the following:

Error producing PDF. ! Package pgfkeys Error: I do not know the key '/tcb/new/number' and I am going to ignore it. Perhaps you misspelled it.

See the pgfkeys package documentation for explanation. Type H for immediate help. ...

l.68 ...ck=cyan!5!white,colframe=cyan!50!black}{thm}

Regardless of the specific error, isn't it possible for pandoc to simply continue running the latex compiler until it exits?

The pandoc command I run is the following:

pandoc -f markdown+pipe_tables+wikilinks_title_after_pipe+mark+lists_without_preceding_blankline+rebase_relative_paths -s --metadata-file="<path to vault>/999 Templates/pandoc.yaml" --fail-if-warnings=false --filter pandoc-crossref -L minted.lua -L noexport.lua -L rule.lua -L callouts.lua --filter pandoc-div2env <file>.md -o output.pdf --pdf-engine=lualatex --pdf-engine-opt=-shell-escape --pdf-engine-opt=-interaction=nonstopmode

kchousos avatar Dec 15 '23 15:12 kchousos

@kchousos Did you choose latex template? If choosen, @universvm should know what is going on because he wrote the template.

mokeyish avatar Dec 15 '23 15:12 mokeyish

No latex template, option is set to None. As stated, this problem persists when calling pandoc directly, so it probably isn't a problem of the plugin.

kchousos avatar Dec 15 '23 15:12 kchousos

are you willing to put this on the wiki?

@mokeyish, thank you very much for creating the wiki. In my free time, I will definitely write about my LaTeX and PDF workflow, along with tips that I have understood or collected from the internet, on the wiki.


This is true if I export to LaTeX and then compile it manually, but exporting to PDF fails at the command line too. The fail-if-warnings option doesn't change it.

@kchousos, since exporting a markdown to TeX doesn't include any actual LaTeX compiling (thus no error there), it will try to follow any template and defaults file you mention, and that is it. I am sorry that my answer earlier was of no help.

Regarding your issue, I believe somewhere you are using the tcolorbox package, or maybe pandoc uses it (if you're not using any template) which is generating the error.

Could you please share the exported TeX file or the markdown file that you want to compile, along with the workflow? This will allow me to take a closer look.

Regardless of the specific error, isn't it possible for pandoc to simply continue running the latex compiler until it exits?

I don't think it would be advisable to generate a PDF when encountering errors during compilation. Doing so differs significantly from handling warnings. Even if a PDF is produced after encountering an error, it's probable that the output will be highly distorted. Furthermore, to my knowledge, there isn't a LaTeX compiler that supports this method, though I could be mistaken.

TheFermi0n avatar Dec 18 '23 16:12 TheFermi0n