https://github.com/dperrymorrow/plain-text-parser
Parser for key value and array pairs in text format
https://github.com/dperrymorrow/plain-text-parser
Last synced: about 1 year ago
JSON representation
Parser for key value and array pairs in text format
- Host: GitHub
- URL: https://github.com/dperrymorrow/plain-text-parser
- Owner: dperrymorrow
- Created: 2012-03-02T22:44:05.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2012-03-02T23:03:10.000Z (over 14 years ago)
- Last Synced: 2025-01-22T01:42:47.544Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 117 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# KeyVal Parser is a plain text parser to php variables
## Usage, consider the following text
title:: The Title
----
intro:: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. **Ut enim ad minim veniam**,
----
helpUrl:: http://google.com
[[bucket]]
title:: Create Your Own Reports
----
body:: Click on the links below to generate your own reports based on competitive sets and date ranges of your choosing.
----
linkUrl:: http://google.com
----
linkLabel:: Link
[[bucket/]]
[[bucket]]
title:: Lorem ipsum dolor sit amet.
----
body:: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
----
linkUrl:: http://google.com
----
linkLabel:: Hey Alex
[[bucket/]]
[[dashboardLink]]
linkUrl:: http://google.com
----
linkLabel:: Link
[[dashboardLink/]]
[[dashboardLink]]
linkHref:: http://google.com
----
linkLabel:: Link
[[dashboardLink/]]
## When parsed like so
$parser = new PostParser( $text );
print_r( $parser->vals );
## Results in
Array(
[title] => The title
[intro] => Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
[helpUrl] => http://google.com
[bucket] => Array
(
[0] => Array
(
[title] => Create Your Own Reports
[body] => Click on the links below to generate your own reports based on competitive sets and date ranges of your choosing.
[linkUrl] => http://google.com
[linkLabel] => Link
)
[1] => Array
(
[title] => Lorem ipsum dolor sit amet.
[body] => Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
[linkUrl] => http://google.com
[linkLabel] => Hey Alex
)
)
[dashboardLink] => Array
(
[0] => Array
(
[linkUrl] => http://google.com
[linkLabel] => Link
)
[1] => Array
(
[linkHref] => http://google.com
[linkLabel] => Link
)
)
)
## By default Parser uses Markdown to parse the values, but can be turned off with
$parser = new PostParser( $text, FALSE );
## Additionally, you can turn off for individual values using ! will keep the value from being marked down.
body::! Dont mark me down man... _i like uderscores_