Open benjifisher opened 8 years ago
Let's make sure we're not referencing orphaned libraries - I'm not sure if there is anyone to maintain PHP Typography - this is the 'home' that I've been able to find: http://kingdesk.com/projects/php-typography/
The one you found (for composer) looks interesting; we can probably do a quick test to see if it does everything we need.
@jpamental:
From adamaveray/PHPTypography on GitHub:
This is an updated version of the original PHP Typography project by KINGdesk, updated to be PSR-0 compatible and available for use with Composer.
Note that "original PHP Typography project" is a link to the same page you found. So I think we are talking about different versions of the same library: although both are labeled 1.21, one has been packaged for composer.
I am a little worried about this text, found on both project pages:
All markup must be valid xHTML, specifically:
- Every element must be closed,
- Every attribute must have a value enclosed in quotes, and
- Tag names and attributes must be lowercase.
No composer, but an updated version of PHP-Typography can be found in the wp-Typography repository here on GitHub. I've taken over development from @kingjeffrey in 2015.
@mundschenk-at Thanks for the comment!
Are you willing to provide the library in a separate repository, with a composer.json
file, or is there some reason not to? If you do, then it will be easier for other projects ...
composer
.@benjifisher I've been thinking about php-Typography to its own repository for some time, as it is basically self-contained anyway. Not sure what's needed for composer
support, though. The coding standard of php-Typography follows WordPress rules, which, among other things, differ in file naming from both PSR-0 and PSR-4).
@mundschenk-at I am not an expert on composer
, but I do not think that PSR-0 nor PSR-4 are required. I am pretty sure that there is a mechanism for specifying custom autoloading.
I think the minimal requirement for being compatible with composer
is to have composer.json
in the project's root directory. The next step is to create an account on Packagist so that people can install with composer require packagist-account-name/php-typography
.
Official docs: https://getcomposer.org/doc/02-libraries.md
My job gives me some time for community contributions, and I have a full day coming up on July 14. If you start a repository for PHP-Typography, then I will submit a PR or two to make it more composer
-friendly. And we could move this discussion to the issues on the new repository.
@benjifisher Thanks for the links and your offer. I currently have a major API restructuring in the works, but I'll try to split off the new php-typography
repository before the 14th.
@benjifisher I am sorry to report that new API isn't finished yet, so I have not yet extracted php-typography
to its own repository. It would probably still be helpful if you could have a look at the state of the code in https://github.com/mundschenk-at/wp-typography/pull/131. Basically, I'm ripping apart the main PHP_Typography
class in favor of individual Node_Fix
and Token_Fix
instances.
The default settings object (and the forwarding set_*
) methods will also be removed. I'd like to maintain compatibility with PHP 5.6 for the moment, though that limits the use of class constants somewhat (specific unicode code points can only be accessed via a function prior to that version). The $regex[]
and $components[]
properties of Settings
will be cut to size with Fix-specific strings being moved there for tighter cohesion.
@mundschenk-at Thanks for keeping my schedule in mind. I am starting to look at the code, and I will see if I can get started.
Can you tell me how to run the tests, or a simple way to check that I have not totally broken the code? I looked at .travis.yml
, but it looks as though it is just running syntax checkers and not the code in the tests/
directory.
@benjifisher grunt phpunit:default
should run the normal test suite (grunt phpunit:coverage
will generate coverage information as well, but that takes longer). At this point, the test coverage is a bit less than 100 percent due to the API changes.
PS: Just calling phpunit
from the main repository directory should work as well.
@benjifisher PHP-Typography is now available via Composer as mundschenk-at/php-typography.
Including libraries with composer
I am not sure what the recommended way is to include an external library with a Drupal module. Looking at the Markdown module (another filter module) it includes external dependencies in its
composer.json
and instructs users who do not install with composer to use the Libraries API and download the dependencies "manually".Typogrify library
Our Typography class is similar to habari-extras/typogrify, but that is not packaged for composer.
There is a composer version at packagist. Its GitHub repo invites us to adapt it for Drupal. It looks different from the version we are using, but it is worth considering.
The Typogrify project page on d.o gives a broken link as its reference to the PHP Typogrify library.
Smartypants
Smartypants seems to be available as michelf/php-smartypants. The GitHub repo michelf/php-smartypants has a custom license. Perhaps we should not include a copy in our distribution.
The Typogrify project page on d.o gives a link to PHP SmartyPants. This looks like the same project, perhaps a different version.
Widon't
The project page on d.o says "Typogrify.module implements Widont". I am not sure whether there is any code borrowed from that WP plugin.