Skip to content

Commit

Permalink
Improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hason committed Mar 6, 2024
1 parent 051db36 commit 1e73541
Showing 1 changed file with 46 additions and 7 deletions.
53 changes: 46 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ This library can be installed via Composer:
Usage
-----

### Automatic front matter detection and parsing

This library can parse all form of front matter:

<table>
<thead><tr><th>YAML (Neon)</th><th>TOML</th><th>Json</th></tr></thead>
<thead><tr><th>YAML (Neon)</th><th>TOML</th><th>Twig</th><th>Pug</th><th>Json</th></tr></thead>
<tbody><tr>
<td>

Expand All @@ -30,9 +32,9 @@ This library can parse all form of front matter:
foo: bar
---

# h1
# Section

paragraph
Text
```

</td>
Expand All @@ -43,9 +45,34 @@ paragraph
foo = bar
+++

# h1
# Section

Text
```

</td>
<td>

```markdown
{#---
foo: bar
---#}

<h1>Section</h1>

<p>{{ foo }}</p>
```

</td>
<td>

```markdown
--
foo: bar

paragraph
h1 Section

p= foo
```

</td>
Expand All @@ -56,15 +83,27 @@ paragraph
"foo": "bar"
}

# h1
# Section

paragraph
Text
```

</td>
</tr></tbody>
</table>

The following code will automatically detect the above front matter types:

```php
<?php

$frontMatter = \Webuni\FrontMatter\FrontMatterChain::create();
$document = $frontMatter->parse($string);

$data = $document->getData();
$content = $document->getContent();
```

### Parse an arbitrary string

```php
Expand Down

0 comments on commit 1e73541

Please sign in to comment.