From 03356fc70957a3bc3e2ce0b5ed30590f81c78a52 Mon Sep 17 00:00:00 2001 From: Michael Ochmann Date: Mon, 28 Feb 2022 16:16:15 +0100 Subject: [PATCH] restructured abi of main class --- src/Parkdown.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Parkdown.php b/src/Parkdown.php index b53fc90..9edcb83 100644 --- a/src/Parkdown.php +++ b/src/Parkdown.php @@ -2,17 +2,26 @@ namespace parkdown; +use DOMDocument; + class Parkdown { - private string $sourceCode; + private string $sourceCode; + private DOMDocument $tree_; public function __construct(string $sourceCode) { - $this->sourceCode= $sourceCode; - } + $this->sourceCode = $sourceCode; - public function html() : void { $lexer = new Lexer($this->sourceCode); $parser = new Parser($lexer->tokenize()); + + $this->tree_ = $parser->parse(); + } + + public function tree() : DOMDocument { + return $this->tree_; + } - echo $parser->parse(); + public function html() : string { + return $this->tree_->saveHTML(); } } \ No newline at end of file