htdebeer / pandocomatic

Automate the use of pandoc

Home Page:https://heerdebeer.org/Software/markdown/pandocomatic/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pandoc.rb:319:in `write': Broken pipe (Errno::EPIPE)

plbt5 opened this issue · comments

I use the following markdown file, ./src/docs/2021_swSemantics.md, generated by Scrivener (only yaml part given):

---
# Standard Scrivener+Pandoc Project YAML metadata
# IMPORTANT: YAML configuration files use SPACES for indentation to define structure, remember to straighten any smart quotes, and don't capitalise metadata keys like "author" or "title", they must be lowercase!
title: "Consolidating Semantic Interoperability in
Contemporary Architectural Paradigms"
author:
  - name: Jonny Doy
    affiliation: 1
    correspondence: Jdoy@university.nl
    equal_contributor: true
  - name: His Colleague
    affiliation: 2
    equal_contributor: true   
  - name: His co-promoter   
    affiliation: 3     
  - name: His Promoter     
    affiliation: 1  
institute:
  - ^1^ First University of Technology (FUT), The Netherlands.
  - ^2^ Ministry of Some Matters, The Netherlands.
  - ^3^ Second University of Physics (SUP), The Netherlands.
keywords:
  - software architectures
  - semantic architectures
  - semantics
  - pragmatics
  - ontology
  - semantic principles
compiled: 11/08/2021
date: Wednesday, 11 August 2021
comments: "To err is human; ... err?"
# Select which templates pandocomatic will use
# you can enter overrides to the templates here as well
pandocomatic_:
  use-template:
    - paper-with-refs-latex
  postprocessors:
    - postprocessors/check_links.sh
---



# Introduction #

I now run pandocomatic in a bash-CLI:

pandocomatic -b -c ./pandocomatic.yaml ./src/docs/2021_swSemantics.md

The ./pandocomatic.yaml in this local directory reads as follows:

### Pandocomatic Configuration ###
# IMPORTANT: 
# YAML configuration files uses spaces for indentation to define structure
#
# Path values are normally relative to the Pandoc data dir: /Users/MYNAME/.pandoc
# so csl/apa.csl will be searched as /Users/MYNAME/.pandoc/csl/apa.csl
# see https://heerdebeer.org/Software/markdown/pandocomatic/#specifying-paths 
#
# This has been updated for the Pandoc V2.11 citeproc engine, not the older filter
templates:
#-----------------------------------------------------------------------------
  myrefs:
    setup: [] #runs a general script to rename or copy files before anything is run
    preprocessors: [] #runs a script on the markdown file itself
    pandoc:
      citeproc: true #this enables the built-in citeproc engine
      bibliography: "./src/bib/CitedByMe-2018_swSemantics.bib" #bibtex file, default search path will be your pandoc data-dir
      csl: "csl/apa.csl" #CSL style file, in the csl/ folder of pandoc data-dir
    metadata:
      reference-section-title: "Bibliography"
      notes-after-punctuation: false #don't put refs after .
      link-citations: true #hyperlink intext references to the bibliography
      csl-hanging-indent: true #try to add hanging indents to formatted bibliogrpahy
    postprocessors: [] #runs on the output file (unless it is binary like docx)
    cleanup: [] #general cleanup script
#-----------------------------------------------------------------------------
  paper-with-refs-latex:
    extends: ['myrefs'] #we can inherit from other templates
    pandoc:
      from: markdown
      to: latex
      template: "templates/custom.latex" #customised pandoc template
      toc: true
      toc-depth: 4
      base-header-level: 2
    metadata: 
      mainfont: 'Hoefler Text'
      sansfont: 'Avenir Next'
      monofont: 'Menlo'
      CJKmainfont: 'PingFang SC'
      lang: 'en-GB'
      papersize: 'A4'
      documentclass: 'article'
      fontsize: '12pt'
      linestretch: '1.75'
      geometry: 'margin=2cm'

Output:

The pandoc option 'base_header_level' (with value '2') is not recognized by paru. This option is skipped.
pandoc	--from=markdown \
	--to=latex \
	--template=/Users/paulbrandt/.local/share/pandoc/templates/custom.latex \
	--toc \
	--toc-depth=4 \
	--citeproc \
	--bibliography=src/bib/CitedByMe-2018_swSemantics.bib \
	--csl=/Users/paulbrandt/.local/share/pandoc/csl/apa.csl
An unexpected error has occurred. You can report this bug via https://github.com/htdebeer/pandocomatic/issues/new.
Traceback (most recent call last):
	19: from /usr/local/bin/pandocomatic:23:in `<main>'
	18: from /usr/local/bin/pandocomatic:23:in `load'
	17: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/bin/pandocomatic:3:in `<top (required)>'
	16: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/pandocomatic.rb:105:in `run'
	15: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_multiple_command.rb:98:in `execute'
	14: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_multiple_command.rb:98:in `each'
	13: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_multiple_command.rb:99:in `block in execute'
	12: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/command.rb:129:in `execute'
	11: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_command.rb:86:in `run'
	10: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_command.rb:135:in `convert_file'
	 9: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_command.rb:184:in `pandoc'
	 8: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_command.rb:184:in `chdir'
	 7: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_command.rb:218:in `block in pandoc'
	 6: from /Library/Ruby/Gems/2.6.0/gems/paru-0.4.2.1/lib/paru/pandoc.rb:157:in `convert'
	 5: from /Library/Ruby/Gems/2.6.0/gems/paru-0.4.2.1/lib/paru/pandoc.rb:318:in `run_converter'
	 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/open3.rb:101:in `popen3'
	 3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/open3.rb:219:in `popen_run'
	 2: from /Library/Ruby/Gems/2.6.0/gems/paru-0.4.2.1/lib/paru/pandoc.rb:319:in `block in run_converter'
	 1: from /Library/Ruby/Gems/2.6.0/gems/paru-0.4.2.1/lib/paru/pandoc.rb:319:in `<<'
/Library/Ruby/Gems/2.6.0/gems/paru-0.4.2.1/lib/paru/pandoc.rb:319:in `write': Broken pipe (Errno::EPIPE)
	16: from /usr/local/bin/pandocomatic:23:in `<main>'
	15: from /usr/local/bin/pandocomatic:23:in `load'
	14: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/bin/pandocomatic:3:in `<top (required)>'
	13: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/pandocomatic.rb:105:in `run'
	12: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_multiple_command.rb:98:in `execute'
	11: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_multiple_command.rb:98:in `each'
	10: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_multiple_command.rb:99:in `block in execute'
	 9: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/command.rb:129:in `execute'
	 8: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_command.rb:86:in `run'
	 7: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_command.rb:135:in `convert_file'
	 6: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_command.rb:184:in `pandoc'
	 5: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_command.rb:184:in `chdir'
	 4: from /Library/Ruby/Gems/2.6.0/gems/pandocomatic-0.2.7.5/lib/pandocomatic/command/convert_file_command.rb:218:in `block in pandoc'
	 3: from /Library/Ruby/Gems/2.6.0/gems/paru-0.4.2.1/lib/paru/pandoc.rb:157:in `convert'
	 2: from /Library/Ruby/Gems/2.6.0/gems/paru-0.4.2.1/lib/paru/pandoc.rb:312:in `run_converter'
	 1: from /Library/Ruby/Gems/2.6.0/gems/paru-0.4.2.1/lib/paru/pandoc.rb:337:in `rescue in run_converter'
/Library/Ruby/Gems/2.6.0/gems/paru-0.4.2.1/lib/paru/pandoc.rb:337:in `throw': uncaught throw #<Paru::Error: Unable to run pandoc via command 'pandoc	--from=markdown \ (UncaughtThrowError)
	--to=latex \
	--template=/Users/paulbrandt/.local/share/pandoc/templates/custom.latex \
	--toc \
	--toc-depth=4 \
	--citeproc \
	--bibliography=src/bib/CitedByMe-2018_swSemantics.bib \
	--csl=/Users/paulbrandt/.local/share/pandoc/csl/apa.csl': Broken pipe>

What have I done wrong?
Thanks for your support!

groetjes
Paul

The issue with the "base_header_level" is caused by paru. The latest version does not seem to support this option! I will add it to paru later this week and publish a new version of both paru and pandocomatic. I'll create an issue for this in paru's repository.

Until then, you can comment the line base-header-level: 2 in pandocomatic.yaml by preceding it with a # character and it will ignore that option for now.

I confirm that by removing / commenting out the statement base-header-level: 2 in pandocomatic.yaml the error:
The pandoc option 'base_header_level' (with value '2') is not recognized by paru. This option is skipped.
disappears.

However, the broken pipe errors remain.

Yes. This error is thrown when pandoc is called, so something seems to be going wrong. Looking at the invocation, the most likely candidate is an issue with your bibliographical database and/or with running citeproc.

I tried your example on my machine, but I cannot reproduce the issue. On the other hand, I used your almost empty input markdown file and a simple bibliography with a single book in it, and I put all the files in the same directory.

Can you try to do that as well? And can you try this command by putting all files in the same directory? Thus the input file, the apa.csl file, and the bibliogrpahy in the same directory and call that pandocomatic command from that same directory?

Resolved the "base_header_level" issue by updating paru to version 0.4.2.2. Please upgrade paru to the latest version and try again.

Note, the pandoc option --base-header-level seems to be deprecated. Pandoc suggests to use option --shift-heading-level-by instead.

  1. I confirm that the paru upgrade to version 0.4.2.2 resolves the error:
    The pandoc option 'base_header_level' (with value '2') is not recognized by paru. This option is skipped.
    Thanks!
  2. Thanks for pointing me at the deprecated status of base_header_level

That is good news. Did you also manage to resolve the issue with your template?