Pandoc Metadata not formatting properly

Hi there,

When I include a pandoc metadata file when I comple my project it is not formatted correctly in the Markdown file. This pandocomatic does not process the outputted *.md file.

my Pandoc metadata file looks like

--- 
author: 
  - name: Immanuel Koks
keywords: 
  - test
  - pandoc
pandocomatic: 
  use-template: 
    - docx-sbl
title: <$projecttitle>
---
<---
# <$t:chapter_txt><$t:chapter_txt>
# <$n:chapter><$n:chapter>
--->

But it comes out as the followng in the .md file

--- 

author: 

\- name: Immanuel Koks
 
keywords: 
 
\- test
 
\- pandoc
 
pandocomatic: 
 
use-template: 
 
\- docx-sbl
 
title: PhD\_Project
 
---
 
\<---

\# OneTwo
 
\# 12
 
---\><!--- --->

This of course will not process as because it is not correctly formatted YAML.

My question is, why doesn’t it transfer as plain text, since my Front matter is formatted “As-is”

The resulting log file is

=== ------------------------------------------------------ ===
=== Scrivomatic V1.0.29 Report @ 2021-10-26 18:08:47 +1300 ===
=== ------------------------------------------------------ ===
 Working directory: /Users/immanuelkoks/OneDrive - University of Otago/PhD/Sandpit
 Initiating with Ruby 2.6.3
===------ Input Options: ------===
#<struct Scrivomatic::OPT input="BAC2\\ origPD.md", output=nil, to=nil, yaml="/Users/immanuelkoks/.local/share/pandoc/pandocomatic.yaml", command="pandocomatic", envpath="/Users/immanuelkoks/bin:/usr/local/bin", build=false, cleanup=false, verbose=true, dry_run=false, open_log=true, data_dir=nil>
===------ Final ENV PATH: ------===
/Users/immanuelkoks/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/Scrivener.app/Contents/Resources/MultiMarkdown/bin
===------ TOOL PATHS: ------===
---pandoc: /usr/local/bin/pandoc | V: 2.14.2
---pandocomatic: /usr/local/bin/pandocomatic | V: 0.2.7.6
---ruby: /usr/bin/ruby | V: ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
---rbenv versions:
---gem: /usr/bin/gem
---python: /usr/bin/python

 … running pandocomatic, please wait …
===------ COMMAND OUTPUT: ------===
:: Running: /usr/local/bin/pandocomatic -c /Users/immanuelkoks/.local/share/pandoc/pandocomatic.yaml --debug BAC2\ origPD.md 
::: An unexpected error has occurred. You can report this bug via https://github.com/htdebeer/pandocomatic/issues/new.
::: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/psych.rb:456:in `parse': (<unknown>): mapping values are not allowed in this context at line 5 column 13 (Psych::SyntaxError)
::: 	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/psych.rb:456:in `parse_stream'
::: 	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/psych.rb:390:in `parse'
::: 	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/psych.rb:277:in `load'
::: 	from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.6/lib/pandocomatic/pandoc_metadata.rb:190:in `block in extract_metadata'
::: 	from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.6/lib/pandocomatic/pandoc_metadata.rb:190:in `map'
::: 	from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.6/lib/pandocomatic/pandoc_metadata.rb:190:in `extract_metadata'
::: 	from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.6/lib/pandocomatic/pandoc_metadata.rb:60:in `load'
::: 	from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.6/lib/pandocomatic/pandoc_metadata.rb:50:in `load_file'
::: 	from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.6/lib/pandocomatic/command/convert_file_multiple_command.rb:50:in `initialize'
::: 	from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.6/lib/pandocomatic/pandocomatic.rb:85:in `new'
::: 	from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.6/lib/pandocomatic/pandocomatic.rb:85:in `run'
::: 	from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.6/bin/pandocomatic:3:in `<top (required)>'
::: 	from /usr/local/bin/pandocomatic:23:in `load'
::: 	from /usr/local/bin/pandocomatic:23:in `<main>'
:: exit status: pid 94485 exit 1

!!!---scrivomatic::runCommand() RETURN non-zero value: /usr/local/bin/pandocomatic -c /Users/immanuelkoks/.local/share/pandoc/pandocomatic.yaml --debug BAC2\ origPD.md !!!

Thanks in advance for your help.

Manny

The metadata needs to be referred to specifically as “Metadata” in the binder, and it must be located at the very top of the compile group. When those two conditions exist, Scrivener will recognise it as such, and insert it into any other metadata that is being produced by the compiler. The section type actually doesn’t matter at that point, it always treats it “as-is” when detected. A few things of note:

  • Given how it is designed to insert, you would only want the metadata keys in there, not the YAML block markers or anything outside of them. Even if the compiler isn’t actually creating any other metadata it will still insert the markers for you.
  • In the Windows version (not relevant to you) there is a bug with placeholders not evaluating, so one would want to keep those in the compile metadata tab.
  • As noted you don’t want actual front matter in here as well. That should be kept in another entry in the binder.
  • For those using full rich text conversion, as you are, this convention also bypasses that behaviour, so you won’t get all of your markup converted to visible text as you normally would.

Thank-you for your quick response.

I thought it would be pretty simple. but I had spewnt long enough hitting my head on a brick wall :crazy_face:to see the answer.

Based on what you said, I did the following

  1. Renamed the file in the binder “Metadata.”
  2. Changed the section type to N/A.
  3. Put the placeholder manipulation script into another file.

It now works as I need it to. Thanks

1 Like

In my sample workflow.scriv project, I don’t use the “Metadata” naming and placing convention (it is called “Pandoc metadata” and is placed outside the manuscript binder hierarchy, the same as @MannyK original setup) but I don’t enable any RTF conversion so then using AS-IS works to keep the pandoc metadata file valid yaml (and I use a scrivener Meta-Data style to add — prefix and suffix).

Probably I should use the “Metadata” naming convention in my sample project as it is more general purpose…

1 Like