├── .github ├── FUNDING.yml └── stale.yml ├── .styleci.yml ├── .editorconfig ├── composer.json ├── LICENSE ├── src └── CommonMarkExtrasExtension.php ├── CONDUCT.md ├── CONTRIBUTING.md ├── README.md └── CHANGELOG.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: colinodell 2 | patreon: colinodell 3 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: recommended 2 | 3 | enabled: 4 | - concat_with_spaces 5 | - strict 6 | 7 | disabled: 8 | - concat_without_spaces 9 | - phpdoc_short_description 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 21 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - on hold 9 | - security 10 | # Label to use when marking an issue as stale 11 | staleLabel: stale 12 | # Comment to post when marking an issue as stale. Set to `false` to disable 13 | markComment: > 14 | This issue has been automatically marked as stale because it has not had 15 | recent activity. It will be closed if no further activity occurs. Thank you 16 | for your contributions. 17 | # Comment to post when closing a stale issue. Set to `false` to disable 18 | closeComment: false 19 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "league/commonmark-extras", 3 | "type": "commonmark-extension", 4 | "description": "Useful extensions for customizing the league/commonmark Markdown parser", 5 | "keywords": ["markdown", "commonmark", "extensions", "extras", "gfm"], 6 | "homepage": "https://github.com/thephpleague/commonmark-extras", 7 | "license": "BSD-3-Clause", 8 | "authors": [ 9 | { 10 | "name": "Colin O'Dell", 11 | "email": "colinodell@gmail.com", 12 | "homepage": "https://www.colinodell.com", 13 | "role": "Lead Developer" 14 | } 15 | ], 16 | "require": { 17 | "php" : "^7.1", 18 | "league/commonmark": "^1.3" 19 | }, 20 | "require-dev": { 21 | "phpunit/phpunit" : "^7.5" 22 | }, 23 | "autoload": { 24 | "psr-4": { 25 | "League\\CommonMark\\Extras\\": "src" 26 | } 27 | }, 28 | "autoload-dev": { 29 | "psr-4": { 30 | "league\\CommonMark\\Extras\\Test\\": "tests" 31 | } 32 | }, 33 | "scripts": { 34 | "test": "phpunit" 35 | }, 36 | "extra": { 37 | "branch-alias": { 38 | "dev-master": "1.3-dev" 39 | } 40 | }, 41 | "abandoned": "league/commonmark" 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2014-2019, Colin O'Dell 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /src/CommonMarkExtrasExtension.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace League\CommonMark\Extras; 13 | 14 | use League\CommonMark\ConfigurableEnvironmentInterface; 15 | use League\CommonMark\Extension\Autolink\AutolinkExtension; 16 | use League\CommonMark\Extension\GithubFlavoredMarkdownExtension; 17 | use League\CommonMark\Extension\SmartPunct\SmartPunctExtension; 18 | use League\CommonMark\Extension\Strikethrough\StrikethroughExtension; 19 | use League\CommonMark\Extension\Table\TableExtension; 20 | use League\CommonMark\Extension\TaskList\TaskListExtension; 21 | use League\CommonMark\Extension\ExtensionInterface; 22 | 23 | /** 24 | * @deprecated The league/commonmark-extras extension is now deprecated. All functionality has been moved into league/commonmark 1.3+, so use that instead. 25 | */ 26 | final class CommonMarkExtrasExtension implements ExtensionInterface 27 | { 28 | public function __construct() 29 | { 30 | @trigger_error(sprintf('league/commonmark-extras is deprecated; use individual extensions or %s from league/commonmark 1.3+ instead', GithubFlavoredMarkdownExtension::class), E_USER_DEPRECATED); 31 | } 32 | 33 | public function register(ConfigurableEnvironmentInterface $environment) 34 | { 35 | $environment->addExtension(new AutolinkExtension()); 36 | $environment->addExtension(new SmartPunctExtension()); 37 | $environment->addExtension(new StrikethroughExtension()); 38 | $environment->addExtension(new TableExtension()); 39 | $environment->addExtension(new TaskListExtension()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. 6 | 7 | Examples of unacceptable behavior by participants include: 8 | 9 | * The use of sexualized language or imagery 10 | * Personal attacks 11 | * Trolling or insulting/derogatory comments 12 | * Public or private harassment 13 | * Publishing other's private information, such as physical or electronic addresses, without explicit permission 14 | * Other unethical or unprofessional conduct. 15 | 16 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. 17 | 18 | This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community in a direct capacity. Personal views, beliefs and values of individuals do not necessarily reflect those of the organisation or affiliated individuals and organisations. 19 | 20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. 21 | 22 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) 23 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/thephpleague/commonmark-extras). 6 | 7 | ## New Extensions & Features 8 | 9 | New extensions and features will only be considered if they meet all of the following criteria: 10 | 11 | 1. The extension/feature is bundled as a standalone extension, preferably under the PHP League. 12 | 2. External dependencies should be avoided where possible - use plain PHP code and common extensions. 13 | 3. Contributions must have a common use case found in other flavors of Markdown like GFM which other people may find useful. 14 | 15 | ## Pull Requests 16 | 17 | - **[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). 18 | 19 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 20 | 21 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 22 | 23 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 24 | 25 | - **Create feature branches** - Don't ask us to pull from your master branch. 26 | 27 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 28 | 29 | - **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](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 30 | 31 | - **Docblocks** - All files should start with the following docblock: 32 | 33 | ~~~ 34 | /* 35 | * This file is part of the league/commonmark-extras package. 36 | * 37 | * (c) Colin O'Dell 38 | * 39 | * Authored by Your Name 40 | * 41 | * For the full copyright and license information, please view the LICENSE 42 | * file that was distributed with this source code. 43 | */ 44 | ~~~ 45 | 46 | The "Authored by" line is optional. 47 | 48 | 49 | ## Running Tests 50 | 51 | ``` bash 52 | $ composer test 53 | ``` 54 | 55 | 56 | **Happy coding**! 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # league/commonmark-extras 2 | 3 | [![Latest Version on Packagist][ico-version]][link-packagist] 4 | [![Software License][ico-license]](LICENSE.md) 5 | [![Build Status][ico-travis]][link-travis] 6 | [![Coverage Status][ico-scrutinizer]][link-scrutinizer] 7 | [![Quality Score][ico-code-quality]][link-code-quality] 8 | [![Total Downloads][ico-downloads]][link-downloads] 9 | 10 | ## DEPRECATED 11 | 12 | **This extension has been deprecated**. All of its functionality now exists in [`league/commonmark`][link-league-commonmark] 1.3+. You can either register the various extensions individually or use the `GithubFlavoredMarkdownExtension` to get full GFM functionality, so you should upgrade to that version of `league/commonmark` and use that instead of this one. 13 | 14 | ## Overview 15 | 16 | **league/commonmark-extras** is a collection of useful GFM extensions and utilities 17 | for the [league/commonmark][link-league-commonmark] project. 18 | 19 | Adding this extension to your project will automatically register these sub-extensions: 20 | 21 | | **Extension** | **Purpose** | 22 | | :------------ | :---------- | 23 | | [league/commonmark-ext-autolink](https://github.com/thephpleague/commonmark-ext-autolink) | Automatically creating links to URLs and email address (without needing the `<...>` syntax) | 24 | | [league/commonmark-ext-smartpunct](https://github.com/thephpleague/commonmark-ext-smartpunct) | Intelligently converts ASCII quotes, dashes, and ellipses to their Unicode equivalents | 25 | | [league/commonmark-ext-strikethrough](https://github.com/thephpleague/commonmark-ext-strikethrough) | Adds support for `~~strikethrough~~` syntax | 26 | | [league/commonmark-ext-table](https://github.com/thephpleague/commonmark-ext-table) | GFM-style tables | 27 | | [league/commonmark-ext-task-list](https://github.com/thephpleague/commonmark-ext-task-list) | GFM-style task lists `- [x] Like this` | 28 | 29 | ## Install 30 | 31 | Via Composer 32 | 33 | ``` bash 34 | $ composer require league/commonmark-extras 35 | ``` 36 | 37 | ## Usage 38 | 39 | This can be added to any new `Environment`: 40 | 41 | ``` php 42 | use League\CommonMark\CommonMarkConverter; 43 | use League\CommonMark\Environment; 44 | use League\CommonMark\Extras\CommonMarkExtrasExtension; 45 | 46 | // Obtain a pre-configured Environment with all the CommonMark parsers/renderers ready-to-go 47 | $environment = Environment::createCommonMarkEnvironment(); 48 | 49 | // REGISTER THIS EXTENSION HERE 50 | $environment->addExtension(new CommonMarkExtrasExtension()); 51 | 52 | // Define your configuration: 53 | $config = []; 54 | 55 | // Now that the `Environment` is configured we can create the converter engine: 56 | $converter = new CommonMarkConverter($config, $environment); 57 | 58 | // Go forth and convert you some Markdown! 59 | echo $converter->convertToHtml('# Hello World!'); 60 | ``` 61 | 62 | ## Change log 63 | 64 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. 65 | 66 | ## Testing 67 | 68 | ``` bash 69 | $ composer test 70 | ``` 71 | 72 | ## Security 73 | 74 | If you discover any security related issues, please email colinodell@gmail.com instead of using the issue tracker. 75 | 76 | ## Credits 77 | 78 | - [Colin O'Dell][link-author] 79 | - [All Contributors][link-contributors] 80 | 81 | ## License 82 | 83 | This library is licensed under the BSD-3 license. See the [LICENSE file](LICENSE) for more information. 84 | 85 | [ico-version]: https://img.shields.io/packagist/v/league/commonmark-extras.svg?style=flat-square 86 | [ico-license]: http://img.shields.io/badge/License-BSD--3-brightgreen.svg?style=flat-square 87 | [ico-travis]: https://img.shields.io/travis/thephpleague/commonmark-extras/master.svg?style=flat-square 88 | [ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/thephpleague/commonmark-extras.svg?style=flat-square 89 | [ico-code-quality]: https://img.shields.io/scrutinizer/g/thephpleague/commonmark-extras.svg?style=flat-square 90 | [ico-downloads]: https://img.shields.io/packagist/dt/league/commonmark-extras.svg?style=flat-square 91 | 92 | [link-packagist]: https://packagist.org/packages/league/commonmark-extras 93 | [link-travis]: https://travis-ci.org/thephpleague/commonmark-extras 94 | [link-scrutinizer]: https://scrutinizer-ci.com/g/thephpleague/commonmark-extras/code-structure 95 | [link-code-quality]: https://scrutinizer-ci.com/g/thephpleague/commonmark-extras 96 | [link-downloads]: https://packagist.org/packages/league/commonmark-extras 97 | [link-author]: https://github.com/colinodell 98 | [link-contributors]: ../../contributors 99 | [link-league-commonmark]: https://github.com/thephpleague/commonmark 100 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All Notable changes to `commonmark-extras` will be documented in this file 4 | 5 | ## [Unreleased][unreleased] 6 | 7 | ## [1.2.0] - 2020-04-04 8 | 9 | ### Deprecated 10 | 11 | **This extension has been deprecated**. All of its functionality now exists in league/commonmark 1.3+ as `GithubFlavoredMarkdownExtension`. 12 | 13 | ## [1.1.0] - 2019-07-13 14 | 15 | ### Added 16 | 17 | - Added table parsing functionality via [league/commonmark-ext-table v2.0.0](https://github.com/thephpleague/commonmark-ext-table/releases/tag/v2.0.0) 18 | 19 | ## [1.0.0] - 2019-06-29 20 | 21 | No changes have been introduced since 1.0.0-beta2. 22 | 23 | ## [1.0.0-beta2] - 2019-06-05 24 | 25 | ### Changed 26 | 27 | - Made this extension compatible with `league/commonmark` 1.0.0-beta4 28 | 29 | ## [1.0.0-beta1] - 2019-05-27 30 | 31 | ### Changed 32 | 33 | - Made this extension compatible with `league/commonmark` 1.0.0-beta1 34 | 35 | ## [0.5.0] - 2019-05-12 36 | 37 | ### Added 38 | 39 | - Added GFM-style task list support via [league/commonmark-ext-task-list v0.1.0](https://github.com/thephpleague/commonmark-ext-task-list/releases/tag/v0.1.0) 40 | 41 | ## [0.4.0] - 2019-04-19 42 | 43 | ### Added 44 | 45 | - Added support for [league/commonmark-ext-strikethrough v0.4.0](https://github.com/thephpleague/commonmark-ext-strikethrough/releases/tag/v0.4.0) 46 | 47 | ## [0.3.0] - 2019-04-10 48 | 49 | ### Changed 50 | 51 | - Made this extension compatible with `league/commonmark` 0.19 52 | 53 | ## [0.2.1] - 2019-03-16 54 | 55 | ### Added 56 | 57 | - Added support for [league/commonmark-ext-autolink v0.2.0](https://github.com/thephpleague/commonmark-ext-autolink/releases/tag/v0.2.0) 58 | 59 | ## [0.2.0] - 2019-03-14 60 | 61 | **All previous functionality has been removed and placed into separate packages!** This library now serves as a meta-package to pull in officially-recommended extensions. 62 | 63 | ### Added 64 | 65 | - Added [league/commonmark-ext-autolink](https://github.com/thephpleague/commonmark-ext-autolink) and [league/commonmark-ext-smartpunct](https://github.com/thephpleague/commonmark-ext-smartpunct) as dependencies 66 | - Added `CommonMarkExtrasExtension` to pull in both of the libraries above 67 | 68 | ### Changed 69 | 70 | - Moved SmartPunct into its own package: 71 | - Moved the Twitter handle parsing into its own package: 72 | - Bumped the minimum PHP version up to 5.6 73 | - Bumped the minimum [league/commonmark](https://github.com/thephpleague/commonmark) version to 0.18.1 74 | 75 | ### Removed 76 | 77 | - Removed all classes implementing SmartPunct and Twitter handle parsing as those now live elsewhere 78 | - Removed support for PHP 5.4, PHP 5.5, and HHVM 79 | 80 | ## [0.1.5] - 2018-09-28 81 | ### Changed 82 | - Added league/commonmark 0.18 as a compatible version 83 | 84 | ## [0.1.4] - 2017-12-31 85 | ### Changed 86 | - Added league/commonmark 0.17 as a compatible version 87 | 88 | ## [0.1.3] - 2017-10-30 89 | ### Changed 90 | - Added league/commonmark 0.16 as a compatible version 91 | - Bumped target spec to 0.28 (no code changes required) 92 | 93 | ## [0.1.2] - 2016-09-19 94 | ### Changed 95 | - Added league/commonmark 0.14 and 0.15 as compatible versions 96 | - Bumped target spec to 0.26 (no code changes required) 97 | 98 | ## [0.1.1] - 2016-01-16 99 | ### Fixed 100 | - Fixed incorrect usage example in the README (#5) 101 | 102 | ## 0.1.0 - 2016-01-13 103 | ### Added 104 | - Created this new library 105 | - Added the SmartPunct functionality from the league/commonmark project 106 | - Added the Twitter handle autolinker example from the league/commonmark docs site (#1) 107 | 108 | ### Changed 109 | - Minor refactoring to SmartPunct's `QuoteParser` to reduce complexity 110 | 111 | [unreleased]: https://github.com/thephpleague/commonmark-extras/compare/1.2.0...HEAD 112 | [1.2.0]: https://github.com/thephpleague/commonmark-extras/compare/1.1.0...1.2.0 113 | [1.1.0]: https://github.com/thephpleague/commonmark-extras/compare/1.0.0...1.1.0 114 | [1.0.0]: https://github.com/thephpleague/commonmark-extras/compare/1.0.0-beta2...1.0.0 115 | [1.0.0-beta2]: https://github.com/thephpleague/commonmark-extras/compare/1.0.0-beta1...1.0.0-beta2 116 | [1.0.0-beta1]: https://github.com/thephpleague/commonmark-extras/compare/0.5.0...1.0.0-beta1 117 | [0.5.0]: https://github.com/thephpleague/commonmark-extras/compare/0.4.0...0.5.0 118 | [0.4.0]: https://github.com/thephpleague/commonmark-extras/compare/0.3.0...0.4.0 119 | [0.3.0]: https://github.com/thephpleague/commonmark-extras/compare/0.2.1...0.3.0 120 | [0.2.1]: https://github.com/thephpleague/commonmark-extras/compare/0.2.0...0.2.1 121 | [0.2.0]: https://github.com/thephpleague/commonmark-extras/compare/0.1.4...0.2.0 122 | [0.1.5]: https://github.com/thephpleague/commonmark-extras/compare/0.1.4...0.1.5 123 | [0.1.4]: https://github.com/thephpleague/commonmark-extras/compare/0.1.3...0.1.4 124 | [0.1.3]: https://github.com/thephpleague/commonmark/compare/0.1.2...0.1.3 125 | [0.1.2]: https://github.com/thephpleague/commonmark/compare/0.1.1...0.1.2 126 | [0.1.1]: https://github.com/thephpleague/commonmark/compare/0.1.0...0.1.1 127 | --------------------------------------------------------------------------------