a recusive descent markdown parser in PHP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
507 B

<?php declare(strict_types=1);
namespace parkdown;
use DOMDocument;
class Parkdown {
private string $sourceCode;
private DOMDocument $tree_;
public function __construct(string $sourceCode) {
$this->sourceCode = $sourceCode;
$lexer = new Lexer($this->sourceCode);
$parser = new Parser($lexer->tokenize());
$this->tree_ = $parser->parse();
}
public function tree() : DOMDocument {
return $this->tree_;
}
public function html() : string {
return $this->tree_->saveHTML();
}
}