Make custom processor work in main file's directory
// Please enter a detailed description of the issue
// Description of the issue:
As alluded to in the description of Custom Processor, Marked 2 does not run the processor in the working directory. This makes it difficult to use local files in the YAML header (bibliography, CSS, etc.).
Working around this issue by writing a wrapper script to change to the directory and then executing the custom preprocessor is possible, but fixing this on the Marked side should be easier and more universal.
(Using absolute paths to files in the YAML header is not useful because it makes documents less portable.)
// Please enter a list of steps required to reproduce the issue
// Steps to reproduce:
1. Configure custom preprocessor "pandoc", args "-s --filter=pandoc-citeproc"
2. Use local bibliography or css in YAML header
3. get error messages that files cannot be found
// If applicable please attach a sample document that causes the issue for you.
---
title: Pandoc Test
author: Bernhard
bibliography: Lit.bib
css: nocounter.css
csl: custom.csl
...
# Test File Contents
Use any bib, css, csl file to test.
// Configuration (do not edit)
Marked 2 910 (Direct)
OS X Version: 10.10.5
---
additionalMathJaxConfig:
allowPageBreakInCode: 1
bookTxtIsLeanpub: 0
codeIsPoetry: 0
collapsibleHeadlines: 1
convertGithubCheckboxes: 1
convertYAMLToMMD: 0
defaultMathJaxConfig: TeX-AMS-MML_HTMLorMML
defaultPreviewStyle: 101
defaultProcessor: MultiMarkdown
enableMiniMap: 1
excludeBlockQuotesFromCounts: 0
excludeFootnotesFromCounts: 0
excludeVerbatimFromCounts: 0
excludeCaptionsFromCounts: 0
folderPreviewExtensionsArray: md, markdown, txt, mdown, html, opml
githubNewlines: 0
h1IsPageBreak: 0
h2IsPageBreak: 0
hrIsPageBreak: 0
includeMathJax: 1
limitTextWidth: 0
minimalJavaScript: 0
outlineModeExtensions:
permissionGranted: 1
printHeaderBottomLeft:
printHeaderBottomRight:
printHeaderFooterFirstPage: 0
printHeaderTopLeft:
printHeaderTopRight:
processHTMLFiles: 1
removeMetadataForPreview: 0
removeYAMLHeaders: 0
scrollToEdit: 1
shouldDetectCritic: 1
shouldHighlightMarkupErrors: 1
shouldLoadCritic: 0
syntaxHighlight: 1
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Brett on 15 Feb, 2016 03:26 PM
When running shell commands from within an app bundle, I do not have
access to the user environment prior to running the command. Marked
sends the text to STDIN, and doesn't actually pass a file with a
location. This is why the environment variables were made available to
shell scripts.
http://marked2app.com/help/Custom_Processor.html#environmentvariables
A simple wrapper script that reads the $MARKED_ORIGIN variable and
performs a `cd` command prior to passing the text to pandoc (`cat |
pandoc [options]) should resolve the problem. It's really not an option
to handle this universally within Marked at this point, as every custom
processor setup will have different requirements.
-Brett
2 Posted by Bernhard on 15 Feb, 2016 03:44 PM
Thank you for your reply!
I do not agree that processor requirements are so unpredictably different, especially with regard to the working directory. Being run in the directory of the main file is quite a common assumption, also for other programs like TeX or roff. (And Marked certainly sees the path of the file that is sent to the processor's STDIN.)
But of course I accept the reasoning that OS X is making running programs the ‘normal’ (unixy) way (increasingly?) difficult. ;-( Maybe, with my expectations, I should rather stick to the more unixy programs.
Sorry for the noise, but thanks again for the quick response,
Bernhard