diff --git a/symposion/constants.py b/symposion/constants.py new file mode 100644 index 00000000..f49455c5 --- /dev/null +++ b/symposion/constants.py @@ -0,0 +1,5 @@ +TEXT_FIELD_MONOSPACE_NOTE=( + "This field is rendered with the monospace font " + "Hack with " + "whitespace preserved") + diff --git a/symposion/markdown_parser.py b/symposion/markdown_parser.py deleted file mode 100644 index f123be47..00000000 --- a/symposion/markdown_parser.py +++ /dev/null @@ -1,17 +0,0 @@ -import logging - -import bleach -import markdown - - -logger = logging.getLogger('MARKDOWN') -logger.setLevel(logging.INFO) - -tags = bleach.sanitizer.ALLOWED_TAGS[:] -tags.extend(['p', 'pre']) - - -def parse(text): - md = markdown.markdown(text, extensions=['extra']) - text = bleach.clean(md, tags=tags) - return text diff --git a/symposion/proposals/models.py b/symposion/proposals/models.py index 2b9d43a1..94568870 100644 --- a/symposion/proposals/models.py +++ b/symposion/proposals/models.py @@ -14,7 +14,8 @@ from django.core.exceptions import ValidationError from model_utils.managers import InheritanceManager from reversion import revisions as reversion -from symposion.markdown_parser import parse +from symposion import constants +from symposion.text_parser import parse from symposion.conference.models import Section from symposion.speakers.models import Speaker @@ -84,9 +85,7 @@ class ProposalBase(models.Model): abstract = models.TextField( _("Abstract"), help_text=_("This will appear in the conference programme. Up to about " - "500 words. Edit using Markdown.") + "500 words. " + constants.TEXT_FIELD_MONOSPACE_NOTE) ) abstract_html = models.TextField(blank=True) @@ -94,9 +93,8 @@ class ProposalBase(models.Model): _("Private Abstract"), help_text=_("This will only be shown to organisers and reviewers. You " "should provide any details about your proposal that you " - "don't want to be public here. Edit using Markdown.") + "don't want to be public here. " + + constants.TEXT_FIELD_MONOSPACE_NOTE) ) private_abstract_html = models.TextField(blank=True) @@ -107,10 +105,8 @@ class ProposalBase(models.Model): "projector, audio. If you require anything in addition, " "please list your technical requirements here. Such as: a " "static IP address, A/V equipment or will be demonstrating " - "security-related techniques on the conference network. " - "Edit using Markdown.") + "security-related techniques on the conference network. " + + constants.TEXT_FIELD_MONOSPACE_NOTE) ) technical_requirements_html = models.TextField(blank=True) diff --git a/symposion/reviews/models.py b/symposion/reviews/models.py index a92bf483..1fc1667b 100644 --- a/symposion/reviews/models.py +++ b/symposion/reviews/models.py @@ -13,7 +13,8 @@ from django.db.models.signals import post_save from django.contrib.auth.models import User from django.utils.translation import ugettext_lazy as _ -from symposion.markdown_parser import parse +from symposion import constants +from symposion.text_parser import parse from symposion.proposals.models import ProposalBase from symposion.schedule.models import Presentation diff --git a/symposion/schedule/models.py b/symposion/schedule/models.py index 0e2307b2..9c738c20 100644 --- a/symposion/schedule/models.py +++ b/symposion/schedule/models.py @@ -5,7 +5,7 @@ from django.contrib.auth.models import User from django.db import models from django.utils.translation import ugettext_lazy as _ -from symposion.markdown_parser import parse +from symposion.text_parser import parse from symposion.proposals.models import ProposalBase from symposion.conference.models import Section from symposion.speakers.models import Speaker diff --git a/symposion/speakers/models.py b/symposion/speakers/models.py index 5ed69866..55397506 100644 --- a/symposion/speakers/models.py +++ b/symposion/speakers/models.py @@ -6,7 +6,8 @@ from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.models import User -from symposion.markdown_parser import parse +from symposion import constants +from symposion.text_parser import parse class Speaker(models.Model): @@ -24,10 +25,8 @@ class Speaker(models.Model): blank=True, help_text=_("This will appear on the conference website and in the " "programme. Please write in the third person, eg 'Alice " - "is a Moblin hacker...', 150-200 words. Edit using " - "" - "Markdown."), + "is a Moblin hacker...', 150-200 words. " + + constants.TEXT_FIELD_MONOSPACE_NOTE), verbose_name=_("Biography"), ) biography_html = models.TextField(blank=True) @@ -36,10 +35,8 @@ class Speaker(models.Model): help_text=_("Have you had any experience presenting elsewhere? If so, " "we'd like to know. Anything you put here will only be " "seen by the organisers and reviewers; use it to convince " - "them why they should accept your proposal. Edit using " - "" - "Markdown."), + "them why they should accept your proposal. " + + constants.TEXT_FIELD_MONOSPACE_NOTE), verbose_name=_("Speaking experience"), ) experience_html = models.TextField(blank=True) @@ -62,9 +59,8 @@ class Speaker(models.Model): accessibility = models.TextField( blank=True, help_text=_("Please describe any special accessibility requirements " - "that you may have. Edit using " - "Markdown."), + "that you may have. " + + constants.TEXT_FIELD_MONOSPACE_NOTE), verbose_name=_("Accessibility requirements")) accessibility_html = models.TextField(blank=True) travel_assistance = models.BooleanField( diff --git a/symposion/text_parser.py b/symposion/text_parser.py new file mode 100644 index 00000000..939d449e --- /dev/null +++ b/symposion/text_parser.py @@ -0,0 +1,9 @@ +import bleach + +tags = bleach.sanitizer.ALLOWED_TAGS[:] +tags.extend(['p', 'pre']) + + +def parse(text): + scrubbed_text = bleach.clean(text, tags=tags) + return scrubbed_text