jghauser / auto-pandoc.nvim

Use pandoc to convert markdown files according to options from a yaml block
GNU General Public License v3.0
34 stars 1 forks source link

Template options #4

Closed plum closed 7 months ago

plum commented 7 months ago

Thanks for a neat plugin. I successfully get aniuce output to pdf using the README suggested yaml block for pandoc options,.

I use additoinal yaml blocks for latex, and latex templates when writing letters, and legal letters more especially. I tried the following:

---
author: Shakespeare
opening: NOTICE Re. my forthcoming demise
closing: Your diligent slave,
address: 
- Name
- street
- etc

return-address:
-  Name
- address one
- etc
...
---
pandoc_:
  - template: '~/.local/share/pandoc/templates/template-letter.tex'
  - output: .pdf
    - defaults: academic
---

I get returned the notifcation: "Pandoc conversion error: Unknown option --emplate."

Note: Yes, it really is --emplate"

John

jghauser commented 7 months ago

thanks for the report! I'm noticing that some of the indentation seems off (both the - template and the - defaults line seem overindented). Is that just a mistake from copying it here? If not, can you fix it in your file and see if still throws an error?

plum commented 7 months ago

thanks for the report! I'm noticing that some of the indentation seems off (both the - template and the - defaults line seem overindented). Is that just a mistake from copying it here? If not, can you fix it in your file and see if still throws an error?

Thanks for kiind reply; Oh that's an error from posting here, clumsily pasting (paste in the browser/git_text_edit_box sems to indent in a naughty manner,)

plum commented 7 months ago

.... ANd of further interest, when I more recently order the yaml block this way,

---
pandoc_:
  - output: .pdf
  - template: '~/.local/share/pandoc/templates/template-letter.tex'
  - defaults: academic
---

"unknown option --efaults" is returned as an error message.

BTW: This remains the same, whether or not i inlcude a latex yaml block

plum commented 7 months ago

Acrrullay the error also occurs with only:

---
pandoc_:
  - defaults: academic
  - output: .pdf
---

I beleived it didn't before, and that -defaults option was ok. gosh.

I can confirm, that right now, a file prints to pdf with just the --output option in the yaml block

jghauser commented 7 months ago

Hmm, I'm using --defaults also and don't have this problem. One more thing I just realised about your examples. You seem to have two yaml blocks in the examples, is that also a mistake that happened while posting here? What I mean is that there's a --- that starts the first standard yaml block, then a ... ending it, and finally another yaml block starting with --- just before pandoc_ and ending with --- after everything. If that's in your own file too, can you try with adding all in one yaml block?

plum commented 7 months ago

Thanks for kind reply JG;

Yes, when I incude all within the one yaml block delimiters it works with the template option! BUT, Not with the - defaults: academic option.

I should add, the template path must not be included with 'PATH' single quotes. or with "PATH" in double quotes.

Strange, I thought I had tried printing with all yaml within a single yaml block, but must have commenced to employ strategy of path in quotes at that time, and failed to observe the clue in the error.

I still get the "unknown option --efaults" is returned as an error message. Well, I'm happy for now, i dont need to use the defaults option right now, but something strange remains, and appears incinsistent too, to me. Below is the Yaml section, which is successful with all but the "- defaults" option.

---
author: Ralph XXXX
opening: NOTICE Re. 
closing: Yours Sincerely,
address: 
- Hard Labour Enforcement Centre
- Village Court Tea Garden
- Back of Beyond  BBB 123

return-address:
- Ralph XXXX
- Fair View, XXXXX
- XXXXXX, XXXXX
pandoc_:
  - output: .pdf
  - template: ~/.local/share/pandoc/templates/template-letter.tex
 -  defaults: acaddemic
---
jghauser commented 7 months ago

Hmm, odd. Once I fix the defaults line in your example (get the line indented right, remove the double space, and the double dd), it works for me (I happen to have a default called academic too). So the following works:

---
author: Ralph XXXX
opening: NOTICE Re. 
closing: Yours Sincerely,
address: 
- Hard Labour Enforcement Centre
- Village Court Tea Garden
- Back of Beyond  BBB 123

return-address:
- Ralph XXXX
- Fair View, XXXXX
- XXXXXX, XXXXX
pandoc_:
  - output: .pdf
  - template: ~/.local/share/pandoc/templates/template-letter.tex
  - defaults: academic
---

Are you sure it's not again a syntax error?

plum commented 7 months ago

Ah, I suspect that I don't acatually have a defaults called 'academic' - and I dont know what that is - perhaps some kind of pandoc template; That may be it. AND, Perhaps the error report itself contains an errror, reporting with one letter missing.

I use a a latex tamplate.

Note: The indentation errors I made are merely due to pasting here, which seems to add tabs to indents.

jghauser commented 7 months ago

Oh, I see! I guess I need to make it clear that the README example is just this: an example. If you don't use pandoc defaults, then you don't need to set that option. So in your case, you only need the - template part. I've added a note to the README and will close this as completed. If you have any other issues, feel free to re-open :). Thanks again!