mokeyish / obsidian-enhancing-export

This is an enhancing export plugin base on Pandoc for Obsidian (https://obsidian.md/ ). It's allow you to export to formats like Markdown、Markdown (Hugo https://gohugo.io/ )、Html、docx、Latex etc.
MIT License
297 stars 17 forks source link

Export to .pdf only when YAML is deleted? #90

Open merlinuwe opened 1 year ago

merlinuwe commented 1 year ago

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.)

universvm commented 1 year ago

Where is this template you are linking to?

merlinuwe commented 1 year ago

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

universvm commented 1 year ago

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.

mokeyish commented 1 year ago

Please try to add newline after YAML?

merlinuwe commented 1 year ago

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]

mokeyish commented 1 year ago

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

universvm commented 1 year ago

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
mokeyish commented 1 year ago

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

merlinuwe commented 1 year ago

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?

universvm commented 1 year ago

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)

mokeyish commented 1 year ago

Try add ./ before your attachmentPath?

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

mokeyish commented 1 year ago

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.

universvm commented 1 year ago

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.

mokeyish commented 1 year ago

@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.