Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3cbbf28
Showing
21 changed files
with
1,208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all test and documentation with "export-ignore". | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/.travis.yml export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/scrutinizer.yml export-ignore | ||
/tests export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/.idea/ | ||
composer.lock | ||
composer.phar | ||
/vendor/ | ||
phpunit.xml | ||
tests/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
filter: | ||
excluded_paths: [tests/*] | ||
checks: | ||
php: | ||
code_rating: true | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: true | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true | ||
tools: | ||
external_code_coverage: | ||
timeout: 1200 | ||
runs: 3 | ||
php_analyzer: true | ||
php_code_coverage: false | ||
php_code_sniffer: | ||
config: | ||
standard: PSR2 | ||
filter: | ||
paths: ['src'] | ||
php_cpd: | ||
enabled: true | ||
excluded_dirs: [vendor, tests] | ||
php_loc: | ||
enabled: true | ||
excluded_dirs: [vendor, tests] | ||
php_pdepend: true | ||
php_sim: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
language: php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- hhvm | ||
|
||
sudo: false | ||
|
||
install: travis_retry composer install --no-interaction --prefer-source | ||
|
||
script: phpunit --coverage-text --coverage-clover=coverage.clover | ||
|
||
after_script: | ||
- wget https://scrutinizer-ci.com/ocular.phar | ||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. | ||
|
||
We accept contributions via Pull Requests on [GitHub](https://github.com/thephpleague/markua). | ||
|
||
|
||
## Pull Requests | ||
|
||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). | ||
|
||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests. | ||
|
||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
|
||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. | ||
|
||
- **Create feature branches** - Don't ask us to pull from your master branch. | ||
|
||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. | ||
|
||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. | ||
|
||
|
||
## Running Tests | ||
|
||
``` bash | ||
$ phpunit | ||
``` | ||
|
||
|
||
**Happy coding**! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Copyright (c) 2014, Davey Shafik | ||
|
||
Based on stmd.js: Copyright (c) 2014, John MacFarlane | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
* Neither the name of Colin O'Dell nor the names of other | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# Markua | ||
|
||
[![Build Status](https://travis-ci.org/dshafik/markua.svg?branch=master)](https://travis-ci.org/dshafik/markua) | ||
|
||
|
||
**league/markua** is a Markdown parser for PHP which intends to support the full [Markua] spec. The Markua spec is [still evolving](https://leanpub.com/markua/read). | ||
|
||
## Goals | ||
|
||
This aims to fully support the Markua specification, and will continue to evolve as the spec does. | ||
|
||
### League\CommonMark | ||
|
||
This package depends on [League\CommonMark](http://commonmark.thephpleague.com) and functions identically | ||
except for using the Markua specification. | ||
|
||
## Installation | ||
|
||
This project can be installed via [Composer]: | ||
|
||
``` bash | ||
$ composer require league/markua | ||
``` | ||
|
||
## Basic Usage | ||
|
||
The `MarkuaConverter` class provides a simple wrapper for converting Markua to HTML: | ||
|
||
```php | ||
use League\Markua\MarkuaConverter; | ||
|
||
$converter = new MarkuaConverter(); | ||
echo $converter->convertToHtml('# Hello World!'); | ||
|
||
// <h1>Hello World!</h1> | ||
``` | ||
|
||
## Advanced Usage & Customization | ||
|
||
The actual conversion process requires two steps: | ||
|
||
1. Parsing the Markdown input into an AST | ||
2. Rendering the AST document as HTML | ||
|
||
Although the `MarkuaConverter` wrapper simplifies this process for you, advanced users will likely want to do this themselves: | ||
|
||
```php | ||
use League\CommonMark\DocParser; | ||
use League\CommonMark\Environment; | ||
use League\CommonMark\HtmlRenderer; | ||
use League\Markua\Environment\Markua; | ||
|
||
// Obtain a pre-configured Environment with all the Markua parsers/renderers ready-to-go | ||
$environment = Environment::createEnvironment(new Markua()); | ||
|
||
// Optional: Add your own parsers/renderers here, if desired | ||
// For example: $environment->addInlineParser(new TwitterHandleParser()); | ||
|
||
// Create the document parser and HTML renderer engines | ||
$parser = new DocParser($environment); | ||
$htmlRenderer = new HtmlRenderer($environment); | ||
|
||
// Here's our sample input | ||
$markdown = '# Hello World!'; | ||
|
||
// 1. Parse the Markdown to AST | ||
$documentAST = $parser->parse($markdown); | ||
|
||
// Optional: If you want to access/modify the AST before rendering, do it here | ||
|
||
// 2. Render the AST as HTML | ||
echo $htmlRenderer->renderBlock($documentAST); | ||
|
||
// The output should be: | ||
// <h1>Hello World!</h1> | ||
``` | ||
|
||
This approach allows you to access/modify the AST before rendering it. | ||
|
||
You can also add custom parsers/renderers by [registering them with the `Environment` class](http://commonmark.thephpleague.com/customization/environment/). | ||
The [league/commonmark documentation][commonmark-docs] provides several [customization examples][docs-examples] such as: | ||
|
||
- [Parsing Twitter handles into profile links][docs-example-twitter] | ||
- [Converting smilies into emoticon images][docs-example-smilies] | ||
|
||
You can also reference the core CommonMark parsers/renderers as they use the same functionality available to you. | ||
|
||
## Compatibility with Markua ## | ||
|
||
This project aims to fully support the entire [Markua Spec]. Other flavors of Markdown may work but are not supported. Any/all changes made to the spec should eventually find their way back into this codebase. | ||
|
||
This package is **not** part of Markua, but rather a compatible derivative. | ||
|
||
## Documentation | ||
|
||
Documentation can be found at [markua.thephpleague.com][docs]. | ||
|
||
## Testing | ||
|
||
``` bash | ||
$ ./vendor/bin/phpunit | ||
``` | ||
|
||
## Stability and Versioning | ||
|
||
While this package does work well, the underlying code should not be considered "stable" yet. The original spec may undergo changes in the near future, which will result in corresponding changes to this code. Any methods tagged with `@api` are not expected to change, but other methods/classes might. | ||
|
||
Major release 1.0.0 will be reserved for when both Markua and this project are considered stable. 0.x.x will be used until that happens. | ||
|
||
SemVer will be followed [closely](http://semver.org/). | ||
|
||
## Contributing | ||
|
||
If you encounter a bug in the spec, please report it to the [Markua] project. Any resulting fix will eventually be implemented in this project as well. | ||
|
||
Please see [CONTRIBUTING](https://github.com/thephpleague/commonmark/blob/master/CONTRIBUTING.md) for additional details. | ||
|
||
## Credits & Acknowledgements | ||
|
||
- [Davey Shafik][@dshafik] | ||
- [Colin O'Dell][@colinodell] | ||
- [John MacFarlane][@jgm] | ||
- [All Contributors] | ||
|
||
## License ## | ||
|
||
**league/markua** is licensed under the BSD-3 license. See the `LICENSE` file for more details. | ||
|
||
[Markua]: http://markua.org/ | ||
[Markua spec]: https://leanpub.com/markua/read | ||
[John MacFarlane]: http://johnmacfarlane.net | ||
[commonmark-docs]: http://commonmark.thephpleague.com/ | ||
[docs]: http://markua.thephpleague.com/ | ||
[docs-examples]: http://commonmark.thephpleague.com/customization/overview/#examples | ||
[docs-example-twitter]: http://commonmark.thephpleague.com/customization/inline-parsing#example-1---twitter-handles | ||
[docs-example-smilies]: http://commonmark.thephpleague.com/customization/inline-parsing#example-2---emoticons | ||
[All Contributors]: https://github.com/thephpleague/markua/contributors | ||
[@colinodell]: https://github.com/colinodell | ||
[@jgm]: https://github.com/jgm | ||
[jgm/stmd]: https://github.com/jgm/stmd | ||
[Composer]: https://getcomposer.org/ | ||
[Davey Shafik]: http://twitter.com/dshafik | ||
[@dshafik]: https://github.com/dshafik |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "league/markua", | ||
"type": "library", | ||
"description": "Markdown parser for PHP based on the Markua spec", | ||
"keywords": ["markdown","parser","markua"], | ||
"homepage": "https://github.com/thephpleague/markua", | ||
"license": "BSD-3-Clause", | ||
"authors": [ | ||
{ | ||
"name": "Davey Shafik", | ||
"email": "me@daveyshafik.com", | ||
"homepage": "http://daveyshafik.com", | ||
"role": "Lead Developer" | ||
} | ||
], | ||
"repositories": [ | ||
{ | ||
"type": "vcs", | ||
"url": "git@github.com:dshafik/commonmark.git" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.3.3", | ||
"league/commonmark": "dev-markua" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "~4.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"League\\Markua\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"League\\Markua\\Tests\\": "tests/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="tests/bootstrap.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="League\Markua Test Suite"> | ||
<directory>tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
|
||
<logging> | ||
<log type="coverage-html" target="tests/output" charset="UTF-8" highlight="true" lowUpperBound="35" highLowerBound="70"/> | ||
</logging> | ||
</phpunit> |
Oops, something went wrong.