Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thephpleague/commonmark-ext-smartpunct
Intelligently converts ASCII quotes, dashes, and ellipses to their Unicode equivalents
https://github.com/thephpleague/commonmark-ext-smartpunct
commonmark commonmark-extension markdown php
Last synced: about 2 months ago
JSON representation
Intelligently converts ASCII quotes, dashes, and ellipses to their Unicode equivalents
- Host: GitHub
- URL: https://github.com/thephpleague/commonmark-ext-smartpunct
- Owner: thephpleague
- License: other
- Archived: true
- Created: 2019-03-11T01:24:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-04T15:24:03.000Z (over 4 years ago)
- Last Synced: 2024-07-19T03:51:29.032Z (2 months ago)
- Topics: commonmark, commonmark-extension, markdown, php
- Language: PHP
- Size: 42 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Smart Punctuation for `league/commonmark`
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-travis]][link-travis]
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
[![Quality Score][ico-code-quality]][link-code-quality]
[![Total Downloads][ico-downloads]][link-downloads]## DEPRECATED
**This extension has been deprecated**. All of its functionality now exists in [`league/commonmark`][link-league-commonmark] 1.3+ under the `League\CommonMark\Extension\SmartPunct` namespace, so you should upgrade to that version and use that bundled extension instead of this one.
## Overview
Intelligently converts ASCII quotes, dashes, and ellipses to their Unicode equivalents. For use with the [`league/commonmark` Markdown parser for PHP](https://github.com/thephpleague/commonmark).
For example, this Markdown...
```md
"CommonMark is the PHP League's Markdown parser," she said. "It's super-configurable... you can even use additional extensions to expand its capabilities -- just like this one!"
```Will result in this HTML:
```html
“CommonMark is the PHP League’s Markdown parser,” she said. “It’s super-configurable… you can even use additional extensions to expand its capabilities – just like this one!”
```## Install
Via Composer
``` bash
$ composer require league/commonmark-ext-smartpunct
```## Usage
Extensions can be added to any new `Environment`:
``` php
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use League\CommonMark\Ext\SmartPunct\SmartPunctExtension;// Obtain a pre-configured Environment with all the CommonMark parsers/renderers ready-to-go
$environment = Environment::createCommonMarkEnvironment();// Add this extension
$environment->addExtension(new SmartPunctExtension());// Set your configuration
$config = [
'smartpunct' => [
'double_quote_opener' => '“',
'double_quote_closer' => '”',
'single_quote_opener' => '‘',
'single_quote_closer' => '’',
],
];// Instantiate the converter engine and start converting some Markdown!
$converter = new CommonMarkConverter($config, $environment);
echo $converter->convertToHtml('# Hello World!');
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Testing
``` bash
$ composer test
```## Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## Credits
- [Colin O'Dell][link-author]
- [John MacFarlane][link-jgm]
- [All Contributors][link-contributors]## License
This library is licensed under the BSD-3 license. See the [License File](LICENSE.md) for more information.
[ico-version]: https://img.shields.io/packagist/v/league/commonmark-ext-smartpunct.svg?style=flat-square
[ico-license]: http://img.shields.io/badge/License-BSD--3-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/thephpleague/commonmark-ext-smartpunct/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/thephpleague/commonmark-ext-smartpunct.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/thephpleague/commonmark-ext-smartpunct.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/league/commonmark-ext-smartpunct.svg?style=flat-square[link-packagist]: https://packagist.org/packages/league/commonmark-ext-smartpunct
[link-travis]: https://travis-ci.org/thephpleague/commonmark-ext-smartpunct
[link-scrutinizer]: https://scrutinizer-ci.com/g/thephpleague/commonmark-ext-smartpunct/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/thephpleague/commonmark-ext-smartpunct
[link-downloads]: https://packagist.org/packages/league/commonmark-ext-smartpunct
[link-author]: https://github.com/colinodell
[link-contributors]: ../../contributors
[link-league-commonmark]: https://github.com/thephpleague/commonmark
[link-jgm]: https://github.com/jgm