Code

Opened 8 years ago

Closed 8 years ago

#2132 closed defect (duplicate)

Markup contrib module return different types for different markups

Reported by: David Larlet <larlet@…> Owned by: adrian
Component: Contrib apps Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I want to use from django.contrib.markup.templatetags.markup import * and after:

MARKUP_CHOICES = (
    ('textile', 'Textile'),
    ('markdown', 'Markdown'),
    ('restructuredtext', 'ReST'),
)

def save(self):
    markup_func = globals()[self.markup]
    self.content_html = markup_func(self.content)
    super(Post, self).save() # Call the "real" save() method.

It works well for textile and markdown but there is an issue with restructuredtext because it returns unicode and not string so I have to do:

    self.content_html = str(markup_func(self.content))

This not really a critical bug but it's annoying because markup functions didn't return the same type... the patch is really easy:
in /django/contrib/markup/templatetags/markup.py, replace :

return parts["fragment"]

by:

return str(parts["fragment"])

I don't know if it's a problem for filters.

Attachments (0)

Change History (1)

comment:1 Changed 8 years ago by adrian

  • Resolution set to duplicate
  • Status changed from new to closed

Closing in favor of #2489.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.