From 1a2af0e9fcb6112d1ee8fe76e46061719bf89345 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 28 Jan 2023 15:43:09 +0100 Subject: [PATCH] Add function `noStandalone` to disable `--standalone` This implementation keeps backwards-compability by adding `--standalone` in `run()` per default but not adding it per default in `execute()`. It still can be set explicitely with `standalone()`, resulting in `execute()` passing `--standalone`. Additionally it can be disabled explicitely with `noStandalone()`, resulting in `run()` not passing `--standalone`. Fixes: #31 Signed-off-by: Jonas --- src/Pandoc.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Pandoc.php b/src/Pandoc.php index 2869cd4..a639133 100644 --- a/src/Pandoc.php +++ b/src/Pandoc.php @@ -19,6 +19,8 @@ class Pandoc protected $input; + protected $standalone = true; + protected $inputFile; protected $from; @@ -127,6 +129,14 @@ public function tocDepth($value) public function standalone() { $this->option('standalone'); + $this->standalone = true; + + return $this; + } + + public function noStandalone() + { + $this->standalone = false; return $this; } @@ -197,10 +207,13 @@ public function execute(array $parameters = []) public function run() { $parameters = [ - '--standalone', '--sandbox', ]; + if ($this->standalone) { + array_push($parameters, '--standalone'); + } + if ($this->inputFile) { array_push($parameters, $this->inputFile); }