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

Using a subset of Typogrify filters #3436

Open
3 tasks done
davidlesieur opened this issue Dec 23, 2024 · 4 comments · May be fixed by #3439
Open
3 tasks done

Using a subset of Typogrify filters #3436

davidlesieur opened this issue Dec 23, 2024 · 4 comments · May be fixed by #3439

Comments

@davidlesieur
Copy link
Contributor

  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.
  • I am willing to lend a hand to help implement this feature.

Feature Request

I appreciate using Typogrify with Pelican, but would like to disable some of the filters it provides.

I'd especially like to disable the widont filter. That filter can sometimes cause text in narrow containers to overflow when the last two words are long, whereas the same text would wrap nicely without the non-breaking space introduced by widont. But the nail on widont's coffin, I think, is the CSS text-wrap property which can do a much better job (with balance or pretty).

One filter I'd definitely want to continue using is smartypants.

I suspect that allowing to select a list of filters might require changes to Typogrify. Any ideas on the best way to solve this? Thanks.

@justinmayer
Copy link
Member

Based on a cursory glance, it seems possible to modify how Pelican invokes Typogrify (along with corresponding changes to the TYPOGRIFY setting) such that individual filters are called instead of the all-in-one typogrify() filter.

That said, I imagine it would be better to make some changes to Typogrify itself in order to make it easier to apply individual filters, and/or selectively disable filters along the lines of: typogrify(text, widont=false)

I plan to publish a new version of Typogrify in January, so if you would be willing to implement some changes to Typogrify and Pelican to enable this kind of flexibility, I would be happy to review, merge, and release new versions in an expedited manner 😊

@davidlesieur
Copy link
Contributor Author

Sounds good. Although each filter is available as a separate function in Typogrify, only the typogrify() function takes the ignore_tags argument. Thus, if Pelican was to call each filter separately and still have the option to ignore some tags, it looks like it would need to duplicate some of what is done in typogrify() (I take this from the function signatures, haven't checked the implementation yet). I agree, it makes more sense to enable this flexibility in Typogrify, then have Pelican use it.

I'll look more closely at this and submit a PR against Typogrify -- not today, but hopefully before your next release!

@justinmayer
Copy link
Member

Great. When you submit your PR, please do so from my fork, which is intended to replace "upstream" as the canonical repository: https://github.com/justinmayer/typogrify

@davidlesieur
Copy link
Contributor Author

Managed to extend my day a little bit. :)

davidlesieur added a commit to davidlesieur/pelican that referenced this issue Dec 27, 2024
@davidlesieur davidlesieur linked a pull request Dec 27, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants