From db657952d14147b55a0bd3479abda6447d90f8b1 Mon Sep 17 00:00:00 2001 From: Aidan Woods Date: Sun, 20 Jan 2019 02:21:20 +0000 Subject: [PATCH] Add DefinitionBook configurable to replace definition data --- src/Configurables/DefinitionBook.php | 54 ++++++++++++++++++++++++++++ src/Parsedown.php | 9 ----- 2 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 src/Configurables/DefinitionBook.php diff --git a/src/Configurables/DefinitionBook.php b/src/Configurables/DefinitionBook.php new file mode 100644 index 0000000..0e73db5 --- /dev/null +++ b/src/Configurables/DefinitionBook.php @@ -0,0 +1,54 @@ + */ + private $book; + + /** + * @param array $book + */ + public function __construct(array $book = []) + { + $this->book = $book; + } + + /** @return self */ + public static function default() + { + return new self; + } + + /** + * @param string $id + * @param _Data $data + * @return self + */ + public function setting($id, array $data) + { + $book = $this->book; + $book[$id] = $data; + + return new self($book); + } + + /** + * @param string $id + * @return _Data|null + */ + public function lookup($id) + { + if (isset($this->book[$id])) { + return $this->book[$id]; + } + + return null; + } +} diff --git a/src/Parsedown.php b/src/Parsedown.php index 6373805..99674e7 100644 --- a/src/Parsedown.php +++ b/src/Parsedown.php @@ -42,9 +42,6 @@ class Parsedown protected function textElements($text) { - # make sure no definitions are set - $this->DefinitionData = []; - # iterate through lines to identify blocks return $this->linesElements(Lines::fromTextLines($text, 0)); } @@ -1739,12 +1736,6 @@ class Parsedown private static $instances = []; - # - # Fields - # - - protected $DefinitionData; - # # Read-Only