Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use settings in the typogrify filter? #13

Open
adrienne opened this issue Dec 22, 2018 · 6 comments
Open

How to use settings in the typogrify filter? #13

adrienne opened this issue Dec 22, 2018 · 6 comments
Labels
documentation Documentation fixes/improvements

Comments

@adrienne
Copy link

adrienne commented Dec 22, 2018

There is no indication of how to use the available "settings" parameter, and I can't sort it out from looking at the code. Please help!

@adrienne adrienne changed the title The word How to use settings in the typogrify filter? Dec 22, 2018
@toddpadwick
Copy link

I've been tryign to figure this out as well. it doesn't seem clear? Can anyone provide support on this?

@adrienne
Copy link
Author

adrienne commented Feb 14, 2019

@toddpadwick - I did actually figure this out. I should probably submit a pull request to add some documentation. In the meantime: You need to create a file called wordsmith.php in your config directory, and it needs to look something like this:

<?php

return [
    'typographySettings' => [
        'set_max_dewidow_length' => 15,
        'set_max_dewidow_pull' => 15,
        'set_hyphenation' => false,
        'set_hyphenate_headings' => false,
        'set_wrap_hard_hyphens' => false,
        'set_email_wrap' => false,
        'set_url_wrap' => false,
        'set_smart_diacritics' => false,
        'set_smart_fractions' => false,
        'set_numbered_abbreviation_spacing' => false,
    ]
];

Figuring out what the actual settings you can use are is a little trickier since no one seems to have a useful list. The best link i've found is actually the config file from the other Craft 3 Typography plugin, Typogrify (they use the same underlying library). That's here: https://github.com/nystudio107/craft-typogrify/blob/v1/src/config.php

You only have to manually set whatever you don't want the default behavior for.

@toddpadwick
Copy link

Excellent, thank you @adrienne . This is helpful.
It's surprising they have such extensive documentation on everything else except the settings?

@michaelrog
Copy link
Member

Adding more docs on this is on my to-do list. (But I definitely would not complain if somebody PR'd the docs to add a reference; that would be heroic!)

@michaelrog michaelrog added the documentation Documentation fixes/improvements label May 10, 2019
@alexroper
Copy link

Passing a settings object doesn't seem to have any effect. Am I doing this right?

{{ 'The quick brown fox jumps over the lazy dog'|typogrify({'set_hyphenation': false}) }}

@tremby
Copy link
Contributor

tremby commented Jan 25, 2022

This could really do with better documentation.

I found that the following does work for me:

{{ "text text text" | typogrify({ set_dewidow: false }) }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation fixes/improvements
Projects
None yet
Development

No branches or pull requests

5 participants