restructured abi of main class

feature/tests
Michael Ochmann 3 years ago
parent 3ea15a3f51
commit 03356fc709
  1. 19
      src/Parkdown.php

@ -2,17 +2,26 @@
namespace parkdown; namespace parkdown;
use DOMDocument;
class Parkdown { class Parkdown {
private string $sourceCode; private string $sourceCode;
private DOMDocument $tree_;
public function __construct(string $sourceCode) { public function __construct(string $sourceCode) {
$this->sourceCode= $sourceCode; $this->sourceCode = $sourceCode;
}
public function html() : void {
$lexer = new Lexer($this->sourceCode); $lexer = new Lexer($this->sourceCode);
$parser = new Parser($lexer->tokenize()); $parser = new Parser($lexer->tokenize());
echo $parser->parse(); $this->tree_ = $parser->parse();
}
public function tree() : DOMDocument {
return $this->tree_;
}
public function html() : string {
return $this->tree_->saveHTML();
} }
} }
Loading…
Cancel
Save