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

Export to .pdf only when YAML is deleted?

Open merlinuwe opened this issue 2 years ago • 14 comments

If I export a note to .pdf, I use this YAML in the note:

---
aliases: [ToDo]
tags: [ToDo, HH23AB, KA01, KA02, KA03, KA04, KA05, KA06, KA07, HH, CT23A, CT, FW23A, FW22A, FW21A, FW, Kritisch]
Dateiname: MarkorToDo.md
filename: MarkorToDo
filenamemd: MarkorToDo.md
filenamemd2: H:\Syncthing\Obsidian/MarkorToDo.md
template: [TEMPLATE Neue Notiz]
erstellt: Samstag, 17. Juni 2023, 19:43:23 Uhr
geändert: Sonntag, 25. Juni 2023, 18:15:30 Uhr
---

The export changes this to

---
aliases:
  - ToDo
tags:
  - ToDo
  - HH23AB
  - KA01
  - KA02
  - KA03
  - KA04
  - KA05
  - KA06
  - KA07
  - HH
  - CT23A
  - CT
  - FW23A
  - FW22A
  - FW21A
  - FW
  - Kritisch
Dateiname: MarkorToDo.md
filename: MarkorToDo
filenamemd: MarkorToDo.md
filenamemd2: H:\Syncthing\Obsidian/MarkorToDo.md
template:
  - TEMPLATE Neue Notiz
erstellt: Samstag, 17. Juni 2023, 19:43:23 Uhr
geändert: Sonntag, 25. Juni 2023, 18:15:30 Uhr
---

Why does it change the markdown file?

The process ends to this output:

image

When I delete the YAML, I can export to pdf.

These are my settings:

image

C:\Users\uwewe\AppData\Local\Pandoc\pandoc.exe

-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" --lua-filter="${luaDir}/pdf.lua" --embed-resources --standalone --metadata title="${currentFileName}" -s -o "${outputPath}" -t pdf

(I alway use newest obsidian, newest pandoc and newest plugins.)

merlinuwe avatar Jun 25 '23 16:06 merlinuwe

Where is this template you are linking to?

DrLeucine avatar Jun 25 '23 18:06 DrLeucine

The template only says from which template (TEMPLATE Neue Notiz) this file was made from. There is no link.

merlinuwe avatar Jun 25 '23 18:06 merlinuwe

Sorry I misunderstood the question. We just introduced a template function but it is unrelated to this problem I think.

@mokeyish may be better suited to help.

DrLeucine avatar Jun 25 '23 21:06 DrLeucine

Please try to add newline after YAML?

mokeyish avatar Jun 26 '23 12:06 mokeyish

A new line makes no difference.

This file works:

---
aliases:
  - Notiz
tags:
  - Notiz
Dateiname: Export plugin testfile.md
filename: Export plugin testfile
filenamemd: Export plugin testfile.md
filenamemd2: H:\Syncthing\Obsidian/Export plugin testfile.md
erstellt: Montag, 26. Juni 2023, 14:34:19 Uhr
geändert: Montag, 26. Juni 2023, 14:39:27 Uhr
---

## 1 Export plugin testfile

## 2 Inhaltsverzeichnis ^toc

- [[#1 Export plugin testfile|1 Export plugin testfile]]
- [[#2 Inhaltsverzeichnis ^toc|2 Inhaltsverzeichnis]]
- [[#3 ErsteÜberschrift|3 ErsteÜberschrift]]
- [[#4 Export plugin testfile|4 Export plugin testfile]]
- [[#5 ErsteÜberschrift|5 ErsteÜberschrift]]
- [[#6 Export plugin testfile|6 Export plugin testfile]]
- [[#7 ErsteÜberschrift|7 ErsteÜberschrift]]

## 3 ErsteÜberschrift





## 4 Export plugin testfile


## 5 ErsteÜberschrift

## 6 Export plugin testfile

## 7 ErsteÜberschrift

But this file works not:


---
aliases: [Notiz]
tags: [Notiz]
Dateiname: Export plugin testfile.md
filename: Export plugin testfile
filenamemd: Export plugin testfile.md
filenamemd2: H:\Syncthing\Obsidian/Export plugin testfile.md
template: [TEMPLATE Neue Notiz]
erstellt: Montag, 26. Juni 2023, 14:34:19 Uhr
geändert: Montag, 26. Juni 2023, 14:42:46 Uhr
---

## 1 Export plugin testfile

## 2 Inhaltsverzeichnis ^toc

- [[#1 Export plugin testfile|1 Export plugin testfile]]
- [[#2 Inhaltsverzeichnis ^toc|2 Inhaltsverzeichnis]]
- [[#3 ErsteÜberschrift|3 ErsteÜberschrift]]

## 3 ErsteÜberschrift

## 4 Export plugin testfile

## 5 Inhaltsverzeichnis ^toc

- [[#1 Export plugin testfile|1 Export plugin testfile]]
- [[#2 Inhaltsverzeichnis ^toc|2 Inhaltsverzeichnis]]
- [[#3 ErsteÜberschrift|3 ErsteÜberschrift]]
- [[#4 Export plugin testfile|4 Export plugin testfile]]
- [[#5 Inhaltsverzeichnis ^toc|5 Inhaltsverzeichnis]]
- [[#6 ErsteÜberschrift|6 ErsteÜberschrift]]
- [[#7 Export plugin testfile|7 Export plugin testfile]]
- [[#8 ErsteÜberschrift|8 ErsteÜberschrift]]
- [[#9 Export plugin testfile|9 Export plugin testfile]]
- [[#10 ErsteÜberschrift|10 ErsteÜberschrift]]

## 6 ErsteÜberschrift

## 7 Export plugin testfile

## 8 ErsteÜberschrift

## 9 Export plugin testfile

## 10 ErsteÜberschrift

The only difference is this line:

template: [TEMPLATE Neue Notiz]

merlinuwe avatar Jun 26 '23 12:06 merlinuwe

Please try wrapping TEMPLATE Neue Notiz in double quotes, or insert a comma between them.

mokeyish avatar Jun 27 '23 11:06 mokeyish

I am not able to reproduce on my machine. Also tried templates. Could it be something related to Windows?

Perhaps, can you try without YAML to see if the problem persists?

Screenshot 2023-06-27 at 07 27 40

DrLeucine avatar Jun 27 '23 14:06 DrLeucine

https://www.w3schools.io/file/yaml-arrays/

mokeyish avatar Jun 27 '23 14:06 mokeyish

When I try to make a pdf-file from this, I get this error message:

image

The resource-path="H:\Syncthing\Obsidian\attachments" seems to be wrong. There is no such path. I have these settings for Defalut location for new attachments:

image


What else I did:

I reinstalled pandoc. It lives here:

image

I installed MikTex (is this necessary?)

pandoc -v gives

image

path gives this:

image

What can I do, to solve the issue?

merlinuwe avatar Jun 28 '23 09:06 merlinuwe

Hi @merlinuwe ,

Can you please install: https://miktex.org ?

I tested your code on windows (the one you said does not work and I was able to produce the attached PDF Untitled.pdf

Also I am not sure I follow this "The resource-path="H:\Syncthing\Obsidian\attachments" seems to be wrong. There is no such path. I have these settings for Defalut location for new attachments:"

In the screenshot you posted, you clearly show that Obsidian will add attachments to the "Attachments" folder:

image

if that folder does not exist, maybe it interferes with you creating documents with images. Either create it and move your images there or modify that field with the folder where you keep your images. (or add your image path to the resource path in Obsidian Enhancing export)

DrLeucine avatar Jun 29 '23 01:06 DrLeucine

Try add ./ before your attachmentPath?

https://github.com/mokeyish/obsidian-enhancing-export/blob/8bec93ac2a831296157c066a531549c5eabdc8c0/src/exporto0o.ts#L68-L73

mokeyish avatar Jun 29 '23 04:06 mokeyish

Can you please install: https://miktex.org ?

@universvm Hi, Wouldn't it be better to make a Typst template? https://typst.app/

Typst is easy to install like the pandoc. a single file executable binary(https://github.com/typst/typst/releases).

It can even be added to automatically download the latest pandoc and typst programs from Github, so that no additional installation is required.

mokeyish avatar Jun 29 '23 05:06 mokeyish

Can you please install: https://miktex.org ?

@universvm Hi, Wouldn't it be better to make a Typst template? https://typst.app/

Typst is easy to install like the pandoc. a single file executable binary(https://github.com/typst/typst/releases).

It can even be added to automatically download the latest pandoc and typst programs from Github, so that no additional installation is required.

I haven't tried it yet, not sure when I'll have time to. It seems promising.

DrLeucine avatar Jun 29 '23 05:06 DrLeucine

@merlinuwe

I've add better printing of generated export command and options.

https://github.com/mokeyish/obsidian-enhancing-export/blob/e64211c4d4f9aad24c902c46dad5f5d63bc834e1/src/exporto0o.ts#L176-L179

Please use the shortcut Ctrl+Shift+I or the F12 key to open DevTools in the Obsidian to see it.

Then extract the generated command and environment variables, then in cmd/bash , configure the environment variables and execute it.

If so, you can see what the problem is, or go to the pandoc community to see how to solve the problem.

If it is found that the generated command is wrong or there is a problem with the environment variable, you can raise it and we will fix it.

mokeyish avatar Jun 30 '23 23:06 mokeyish