nystudio107 / craft-typogrify

Typogrify prettifies your web typography by preventing ugly quotes and 'widows' and more
https://nystudio107.com/
MIT License
70 stars 13 forks source link

Use mundschenk-at/php-typography #1

Closed mundschenk-at closed 7 years ago

mundschenk-at commented 7 years ago

Might I suggest using mundschenk-at/php-typography? There have been quite a lot of improvements since I took over development from KINGDESK.

khalwat commented 7 years ago

I saw that; but it also looked like a number of API changes as well.

I do plan to look into refactoring and using your library, as I want something that is maintained! :)

mundschenk-at commented 7 years ago

Two things that have changed: The class name for the main class and that the settings are a separate entity and not part of the PHP_Typography class anymore (i.e. you need an additional parameter). So yes, it's not a drop-in replacement, but the necessary adaptions should be fairly limited.

khalwat commented 7 years ago

Yeah the reason why I didn't tackle it immediately was that I created my own settings model (with validators):

https://github.com/nystudio107/craft3-typogrify/blob/master/src/models/Settings.php

And I wasn't sure how much work it was going to be to use your new fork with its own settings model with my settings model layered on top.

I suspect we created them for similar reasons, so it shouldn't be too bad, but when faced with the unknown, I err on the side of caution.

I'm going to give it a whirl today.

khalwat commented 7 years ago

@mundschenk-at is there any chance we can get an actual version field in the composer.json so I don't have to do dev-master@dev?

khalwat commented 7 years ago

Ah never mind, I see you're doing it with tags instead of a version number in the composer.json

khalwat commented 7 years ago

Switched over in version 1.0.2:

https://github.com/nystudio107/craft3-typogrify/releases/tag/1.0.2

Two minor problems I encountered:

All fixed up, thanks for the push to move to your library, and thank you for maintaining it!

mundschenk-at commented 7 years ago

You can enable lenient error handling by using set_ignore_parser_errors( true ). The resulting HTML will be a "best guess" by the parser, so there might be side effects. The handler callback is only needed if you want a more finegrained control over parser errors.

I just had a look at the set_smart_quotes_* functions and you are right, originally they also accepted the empty string. I don't remember when this changed, but it was probably when I first refactored the (redundant) code in those functions in 2015. Nowadays, the preferred way is to use the constants from PHP_Typography\Settings\Quote_Style.

khalwat commented 7 years ago

Great, thanks for your reply, I'll make some adjustments. Much appreciate you maintaining this wonderful library!