haghish / markdoc

A literate programming package for Stata which develops dynamic documents, slides, and help files in various formats
http://haghish.com/markdoc
87 stars 30 forks source link

UNC paths on Windows #24

Closed mronkko closed 5 years ago

mronkko commented 6 years ago

MarkDoc currently fails to include images if the current working directory is a UNC path. This occurs because the windows shell cannot understand UNC paths and when launched using a UNC path, the shell starts in the system directory. This means that all relative links to images will point to incorrect place.

This can be fixed by passing the current working dir as resource path to Pandoc.

I would have submitted this as a pull request, but the --resource-path option requires Pandoc 2.0 and is not included n the 1.3 version of Pandoc that is currently installed with MarkDoc.

`` // If the working directory is a Windows UNC path, // we need to give pandoc the current working directory // as resourcepath

 if c(os) == "Windows" & substr(c(pwd),1,2) == "\\" {
  local resourcepath --resource-path="`=c(pwd)'"
  di "RESOURCEPATH"
 }

 if "`noisily'" == "noisily" {
  di _n(2) "{title:Executing Pandoc Command}" _n
  di `""$pandoc" `mathjax' `toc' "'    ///
  `"`reference' "`md'" -o "`output'" `resourcepath'"'
 }
 shell "$pandoc" `mathjax' `toc'   ///
 `reference' "`md'" -o "`output'" `resourcepath'  

``

This code has been tested and it works in our computer lab.

haghish commented 5 years ago

I'm back to fix this issue for the new release.

The previous patch that you provided (using temp files before printing the PDF document) causes a new problem for wkhtmltopdf, namely the temporary file will have invalid figure paths (which are defined locally, relative to the working directory.

For this, I am adding an option named unc which is aiming to change the behavior of markdoc when it is accessed from a windows server.

haghish commented 5 years ago

problem is solved with markdoc mini, which is independent of third-party software.