TopShelfCraft / Wordsmith

A plugin for Craft CMS to help you manage and manipulate text.
Other
30 stars 20 forks source link

How to use settings in the typogrify filter? #13

Open adrienne opened 5 years ago

adrienne commented 5 years ago

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!

toddpadwick commented 5 years ago

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

adrienne commented 5 years ago

@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 commented 5 years ago

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

michaelrog commented 5 years ago

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!)

alexroper commented 4 years ago

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 commented 2 years ago

This could really do with better documentation.

I found that the following does work for me:

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