implemented horizontal rules.

closes #1
feature/tests
Michael Ochmann 3 years ago
parent 3025f885f7
commit b61060302c
  1. 6
      README.md
  2. 19
      src/Parser.php
  3. 0
      tests/paragraph.md
  4. 0
      tests/test1.md

@ -12,6 +12,7 @@ Parkdown currently support the following block types:
* tables *(with alignment specification)*
* paragraphs
* block quotes
* horizontal rules `---`
### Supported inline types
Parkdown currently support the following block types:
@ -43,7 +44,12 @@ or via reference to [a later defined url][massivedynamic], i we so desire.
![this is an alt text](https://images.unsplash.com/photo-1571171637578-41bc2dd41cd2?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&h=300&w=1740&q=80)
### Horizontal rules
```markdown
---
```
---
### Block quotes
```markdown
> Only two things are infinite,

@ -457,6 +457,22 @@ class Parser {
$this->document->appendChild($elm);
}
private function parseHorizontalRule() : void {
if (!($this->next()->type === TokenType::MINUS &&
$this->peek(2)->type === TokenType::MINUS &&
$this->peek(3)->type === TokenType::EOL)) {
$this->buildParagraph($this->parseText());
return;
}
$this->consume(); // -
$this->consume(); // -
$this->consume(); // -
$this->consume(); // EOL
$elm = $this->document->createElement("hr");
$this->document->appendChild($elm);
}
public function parse() : DOMDocument {
while ($this->current()->type !== TokenType::EOF) {
switch($this->current()->type) {
@ -484,6 +500,9 @@ class Parser {
case TokenType::GT:
$this->parseBlockQuote();
break;
case TokenType::MINUS:
$this->parseHorizontalRule();
break;
case TokenType::TEXT:
default:
$this->buildParagraph($this->parseText(true));

Loading…
Cancel
Save