montylounge / django-mingus

a Django blog engine leveraging reusable apps for all its features.
Other
508 stars 96 forks source link

Whitespace is stripped from blog posts #42

Closed scelis closed 14 years ago

scelis commented 14 years ago

My blog is a technical blog and I often post code snippets. Sadly, django-mingus currently strips all extraneous whitespace from blog posts. I have investigated this issue and have narrowed it down to the _renderinlines filter in django-basic-apps.

In src/django-basic-apps/basic/inlines/parser.py, the inlines function makes use of the BeautifulStoneSoup class. This class sets PRESERVE_WHITESPACE_TAGS to an empty list while the BeautifulSoup class sets it to contain both the pre and textarea tags.

Sure enough, if I edit the BeautifulSoup code to set pre as a PRESERVE_WHITESPACE_TAG for BeautifulStoneSoup, everything works perfectly and my whitespace is no longer stripped.

So it appears to me that there are a few possible solutions:

  1. Do not use the _renderinlines filter in mingus templates.
  2. Modify django-basic-apps to use a custom BeautifulSoup parser that extends BeautifulStoneSoup but sets PRESERVE_WHITESPACE_TAGS to something that makes sense for mingus.
  3. Patch BeautifulSoup to allow developers to set custom PRESERVE_WHITESPACE_TAGS for each instance of the BeautifulStoneSoup parser.

What are your thoughts on this whole situation? I can very easily do (1) for my personal mingus install, but it would be nice to fix this for all mingus users.

montylounge commented 14 years ago

Hey scellis!

Thanks for taking the time to narrow down the issue.

There's also the 'slimmer.middleware.CompressHtmlMiddleware' middleware and that maybe playing a role in your situation.

Mingus won't be updated to support patching BSoup or further forking django-basic-apps to support the change request.

I know a handful of technical blogs, including my own, that are functioning just fine with the current configuration.

So, that being said, I would suggest updating your installation to resolve your issue.

Thanks for using Mingus!

scelis commented 14 years ago

Hi montylounge,

I just wanted to let you know that I had already disabled 'slimmer.middleware.CompressHtmlMiddleware'. I am experiencing this with the latest version of mingus. I came across this while updating my install and it definitely happens with a clean, up-to-date install of mingus. It's an issue in the latest version of the _renderinlines filter.

Thanks,

Sebastian

montylounge commented 14 years ago

Thx!