htdebeer / pandocomatic

Automate the use of pandoc
https://heerdebeer.org/Software/markdown/pandocomatic/
GNU General Public License v3.0
158 stars 14 forks source link

Can't get a minimal example working... #11

Closed iandol closed 7 years ago

iandol commented 7 years ago

Hi, not sure what I'm doing wrong. Here is my min.md markdown:

---  
title: "Minimal Test"
bibliography: /Users/ian/.pandoc/core.bib  
csl: /Users/ian/.pandoc/apa.csl  
pandocomatic_:
  use-template: test
  output: min.html
---  

# Summary #  

The background question is sound [@shipp2013], and of substantial importance for systems neuroscience.  

And my ~/.pandoc/pandocomatic.yaml

templates:
  test:
    preprocessors: []
    pandoc:
      from: markdown
      to: html5
      standalone: true
      filter: /usr/local/bin/pandoc-citeproc
      dpi: 300
      toc: false
    postprocessors: []

So I assume in theory I don't need to specify an output file on the command line as it is specified in the markdown yaml. But when I try this:

πŸ‘‰  pandocomatic -i min.md
Error writing file: no implicit conversion of nil into String.

It doesn't work. And even if I do specify -o it seems to be ignoring my template (no bibliography):

πŸ‘‰  pandocomatic -i min.md -o min.html; cat min.html
Pandocomatic needed 0.1 seconds to convert 'min.md' to 'min.html'.
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="generator" content="pandoc">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
  <title>Minimal Test</title>
  <style type="text/css">code{white-space: pre;}</style>
  <!--[if lt IE 9]>
    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
  <![endif]-->
</head>
<body>
<header>
<h1 class="title">Minimal Test</h1>
</header>
<h1 id="summary">Summary</h1>
<p>The background question is sound <span class="citation" data-cites="shipp2013">[@shipp2013]</span>, and of substantial importance for systems neuroscience.</p>
</body>
</html>

Also, if I force specify the -c config I get a different result (not standalone, no bibliography):

πŸ‘‰  pandocomatic -c /Users/ian/.pandoc/pandocomatic.yaml -i min.md -o min.html; cat min.html
Pandocomatic needed 0.1 seconds to convert 'min.md' to 'min.html'.
<h1 id="summary">Summary</h1>
<p>The background question is sound <span class="citation">[@shipp2013]</span>, and of substantial importance for systems neuroscience.</p>

I've done something wrong somewhere!


Output from plain pandoc:

πŸ‘‰  pandoc -s --filter pandoc-citeproc -f markdown -t html5 -o min.html min.md; cat min.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="generator" content="pandoc">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
  <title>Minimal Test</title>
  <style type="text/css">code{white-space: pre;}</style>
  <!--[if lt IE 9]>
    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
  <![endif]-->
</head>
<body>
<header>
<h1 class="title">Minimal Test</h1>
</header>
<h1 id="summary">Summary</h1>
<p>The background question is sound <span class="citation" data-cites="shipp2013">(Shipp, Adams, &amp; Friston, 2013)</span>, and of substantial importance for systems neuroscience.</p>
<div id="refs" class="references">
<div id="ref-shipp2013">
<p>Shipp, S., Adams, R., &amp; Friston, K. J. (2013). Reflections on agranular architecture: Predictive coding in the motor cortex. <em>Trends in Neuroscience</em>, <em>36</em>(12), 706–716. <a href="https://doi.org/10.1016/j.tins.2013.09.004" class="uri">https://doi.org/10.1016/j.tins.2013.09.004</a></p>
</div>
</div>
</body>
</html>
htdebeer commented 7 years ago

This was an odd one!

But I found the issue: the YAML block starts by "--- ". Apparently, due to that trailing whitespace, pandocomatic does not recognize it as a start of a YAML block...

That is something I'll have to fix.

htdebeer commented 7 years ago

Fixed in version 0.1.3: you now can end a YAML metadata block delimiter (--- or ...) with whitespace.

Note. version 0.1.3 is not yet pushed to Rubygems, first the other issues have to be fixed, but you can download and install it from here in the meantime.

iandol commented 7 years ago

Great! Because of Pandoc paragraph formatting I have an automatic mania to use double spaces at the end of everything πŸ˜ƒ