Make custom processor work in main file's directory

Bernhard

15 Feb, 2016 03:14 PM

// 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
---
allowPageBreakInCode: 1
bookTxtIsLeanpub: 0
codeIsPoetry: 0
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
processHTMLFiles: 1
scrollToEdit: 1
shouldDetectCritic: 1
shouldHighlightMarkupErrors: 1
syntaxHighlight: 1

1. Support Staff Posted by Brett on 15 Feb, 2016 03:26 PM

When running shell commands from within an app bundle, I do not have
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

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

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help Blurs the current field

Comment Form

r Focus the comment reply box Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

 23 Jun, 2017 05:19 AM Add an option to hide/show status bar 22 Jun, 2017 09:43 PM opml title node from markdown? 20 Jun, 2017 07:25 PM Issue with font sizes in CSS 19 Jun, 2017 03:21 PM SVG support 16 Jun, 2017 10:21 PM Print header and footer variables

Recent Articles

 Relative paths in included files Intra-document links in exported PDFs Custom processor permissions in MAS version License code has already been utilized A URL won't validate or returns "Unknown"