jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.61k stars 3.38k forks source link

paths using a tilde prefix not discovered with --self-contained #3135

Closed kevinushey closed 7 years ago

kevinushey commented 8 years ago

This might be intentional / by design, but wanted to log for posterity. Suppose we do have an image at the path ~/scratch/image.png, and the following Markdown file:

# Hello Markdown
![An Image](~/scratch/image.png)

Attempting to call pandoc with this gives:

kevin@cdrv:~/scratch
$ pandoc hello.md --self-contained
pandoc: Could not fetch ~/scratch/test.png
~/scratch/test.png: openBinaryFile: does not exist (No such file or directory)

This example works fine with a full path rather than an aliased path. Any chance pandoc could do tilde expansion on paths for self-contained documents (replacing with the value of an environment variable, e.g. HOME (USERPROFILE on Windows)?


``` $ pandoc --version pandoc 1.17.2 Compiled with texmath 0.8.6.4, highlighting-kate 0.6.2.1. Syntax highlighting is supported for the following languages: abc, actionscript, ada, agda, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d, diff, djangotemplate, dockerfile, dot, doxygen, doxygenlua, dtd, eiffel, elixir, email, erlang, fasm, fortran, fsharp, gcc, glsl, gnuassembler, go, hamlet, haskell, haxe, html, idris, ini, isocpp, java, javadoc, javascript, json, jsp, julia, kotlin, latex, lex, lilypond, literatecurry, literatehaskell, llvm, lua, m4, makefile, mandoc, markdown, mathematica, matlab, maxima, mediawiki, metafont, mips, modelines, modula2, modula3, monobasic, nasm, noweb, objectivec, objectivecpp, ocaml, octave, opencl, pascal, perl, php, pike, postscript, prolog, pure, python, r, relaxng, relaxngcompact, rest, rhtml, roff, ruby, rust, scala, scheme, sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, tcsh, texinfo, verilog, vhdl, xml, xorg, xslt, xul, yacc, yaml, zsh Default user data directory: /Users/kevin/.pandoc Copyright (C) 2006-2016 John MacFarlane Web: http://pandoc.org This is free software; see the source for copying conditions. There is no warranty, not even for merchantability or fitness for a particular purpose. ```
jgm commented 8 years ago

The tilde expansion is done by the shell and varies from one shell to another. It doesn't seem any more appropriate for pandoc to expand ~ than it would be for pandoc to expand ? or * or $HOME.

jkr commented 8 years ago

Should there be some pandoc convention, though, for refering to $HOME? I have a single default bib file for all my academic writing, and I can't refer to it in YAML in a way that will work on both OSX and linux. I usually solve this by using a Makefile, which enters the bib as a command-line option. But in quick one-offs, it would be nice to refer to it in the YAML. Similarly, I can imagine there might be folks who want to use a resource in an image across multiple files (say, a company logo for letters) without copying it into each project dir.

jgm commented 7 years ago

Closing this. @jkr, re your question, I think a better approach would be some kind of environment variable that pandoc-citeproc would look in for bibliography files, see #3212.