meeb / django-distill

Minimal configuration static site generator for Django
MIT License
441 stars 35 forks source link

 character being generated by distill-local #64

Closed kiernanlabs closed 1 year ago

kiernanlabs commented 2 years ago

Hello, I am using django-distill to build a site locally and when I generate the site, every time I use the builtin humanize "naturaltime" filter an "Â" character is inserted in between the number and the time (e.g. "19Â hours ago"). This is not occurring on either my development server, or the production apache server I am using - only during the local generation of django-distill.

Any ideas where I might be able to go to fix this? Do I need to specify utf8 encoding somewhere for django-distill to use? Thanks so much for the help!

meeb commented 2 years ago

What's your settings.LANGUAGE_CODE set to? Also is LocaleMiddleware loaded?

meeb commented 1 year ago

There isn't actually anything wrong here, everything is working correctly (really). The humanize template tags do not return spaces between some values, they return Unicode non-breaking spaces. These aren't ASCII spaces \x20 they are the Unicode character \xc2\xa0. More info is available here:

https://en.wikipedia.org/wiki/Non-breaking_space

This means that the output of django_distill is the same as you are getting in your local development server and production server. The reason you are seeing  appear is likely because you are not setting the Content-Type header correctly on static HTML files, which should be something like:

Content-Type: text/html; charset=utf-8

(your web server is probably missing the charset=utf-8 part off). This is being set for you by Django when the site is being executed by Python which is why the page works correctly when not being statically rendered.

You probably need to add something like this to your Apache config:

AddDefaultCharset utf-8

or possibly this:

AddCharset utf-8 .html

In summary, this is likely a configuration issue with your Apache web server and the way you are serving statically written HTML files and not to do with DJango or django_distill.

I've added some tests to confirm this behaviour as well.

kiernanlabs commented 1 year ago

Thank you!

On Thu, Mar 30, 2023 at 3:11 AM meeb @.***> wrote:

Closed #64 https://github.com/meeb/django-distill/issues/64 as completed.

— Reply to this email directly, view it on GitHub https://github.com/meeb/django-distill/issues/64#event-8883932786, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD3BKFF2X45Z7ZXEYDT4BS3W6UW2TANCNFSM6AAAAAAQSDHY4E . You are receiving this because you authored the thread.Message ID: @.***>