added readme as test

feature/tests
Michael Ochmann 3 years ago
parent b7eeae8626
commit 7f70681411
  1. 90
      README.md
  2. 9
      index.php
  3. 2
      src/Parser.php
  4. 2
      test/paragraph.md

@ -0,0 +1,90 @@
# Parkdown
– a simple recursive descent Markdown parser for PHP
![Markdown is a simple markup language](https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg)
## Specification
### Supported block types
Parkdown currently support the following block types:
* codeblocks *(with the ability to specify a language for the code block)*
* tables *(with alignment specification)*
* paragraphs
### Supported inline types
Parkdown currently support the following block types:
* bold text (`**bold**`)
* italic text (`*italic*`)
* code snippets
* images (`![alt text](src url)`)
* links (`[link text][url or reference]`)
### Additional functionality
* references (`[marker]: URL`)
## Examples
### Paragraphs
```markdown
A simple paragraph can contain **bold text**, `inline codeblocks` and *italic text*. We can also link [with a direct url][https://google.com] *(i.e. to google)*
or via reference to [a later defined url][massivedynamic], i we so desire.
```
A simple paragraph can contain **bold text**, `inline codeblocks` and *italic text*. We can also link [with a direct url][https://google.com] *(i.e. to google)*
or via reference to [a later defined url][massivedynamic], i we so desire.
### Images
```markdown
\!\[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\)
```
![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)
### Code blocks
```markdown
\`\`\`php
function main(int $argc, array $argv) : int {
echo "Hello World!";
return 0;
}
\`\`\`
```
```php
function main(int $argc, array $argv) : int {
echo "Hello World!";
return 0;
}
```
### Tables
```markdown
| Product name | Amount | Price |
|--------------|-----:----|-------:|
| Football | 7 | $18,00 |
| Golfball | 122 | $7,00 |
| Fooseball | 355 | $1,00 |
| Puck | 58 | $12,00 |
```
| Product name | Amount | Price |
|--------------|-----:----|-------:|
| Football | 7 | $18,00 |
| Golfball | 122 | $7,00 |
| Fooseball | 355 | $1,00 |
| Puck | 58 | $12,00 |
### References
```markdown
[massivedynamic]: https://massivedynamic.eu
```
[massivedynamic]: https://massivedynamic.eu

@ -3,10 +3,15 @@
require __DIR__."/vendor/autoload.php"; require __DIR__."/vendor/autoload.php";
$source = file_get_contents(dirname(__FILE__)."/test/test1.md"); $source = file_get_contents(dirname(__FILE__)."/README.md");
//$source = file_get_contents(dirname(__FILE__)."/test/paragraph.md");
echo " echo "
<style> <style>
body {
font-family: sans-serif;
}
table { table {
width: 100%; width: 100%;
} }
@ -14,4 +19,4 @@ echo "
"; ";
$Instance = new parkdown\Parkdown($source); $Instance = new parkdown\Parkdown($source);
$Instance->html(); echo $Instance->html();

@ -306,7 +306,7 @@ class Parser {
$this->consume(); $this->consume();
} }
$elm = $this->document->createElement("code", $buffer); $elm = $this->document->createElement("code", htmlspecialchars($buffer));
$container->appendChild($elm); $container->appendChild($elm);
$this->document->appendChild($container); $this->document->appendChild($container);
$this->consume(); $this->consume();

@ -0,0 +1,2 @@
This is line one.
This is line two.
Loading…
Cancel
Save