Login

Tag "text"

Snippet List

CompressedTextField

A CompressedTextField to transparently save data gzipped in the database and uncompress at retrieval. Full description at my blog: [arnebrodowski.de/...Field-for-Django.html](http://www.arnebrodowski.de/blog/435-Implementing-a-CompressedTextField-for-Django.html)

  • text
  • model
  • field
  • compressed
Read More

Automatic Paragraphs

I just converted the autop filter from Drupal (which is itself based on a Wordpress filter) from PHP to Python. I had to change the format of the regular expressions a bit and make them raw strings, but otherwise the function is unchanged. It should work exactly like the original function.

  • filter
  • text
  • format
Read More

Make a string a fixed-width

This snippet is a template filter based on ["truncate letters"](http://www.djangosnippets.org/snippets/126/) only it will either truncate or pad a string to ensure the output is always a set width.

  • text
  • fixed-width
Read More

simple text image view

**Credit goes to** [Andrew Gwozdziewycz](http://www.23excuses.com/2006/Jun/30/simple-django-view-for-dynamic-text-replacement/) and [Jacob Kaplan-Moss](http://www.jacobian.org/writing/2006/jun/30/improved-text-image-view/) This is basically their code. Only differences: * orientation can be customized * size can be customized * GIF-Image with transparency is created Note: Because of the minimum palette that's used, the font isn't antialiased/smoothened. My url for this view looks like so: (r'^img/(?P<fontalias>\w+)/(?P<orientation>(normal|left|right))/$', 'view.text_to_image')

  • text
  • image
  • text-image-view
Read More

convert plain text to html

Convert plain text to html. For example: text="""aabhttp://www.example.com http://www.example.com http://www.example.com <<< [<aaaa></aaaa>] """ print plaintext2html(text) It can convert url text to html href. And it also can convert space to &nbsp;. So if you paste python code, the indent will not lost at all. Default it'll convert \t to 4 spaces.

  • text
Read More

20 snippets posted so far.