diff --git a/server/books/schema/mutations/contentblock.py b/server/books/schema/mutations/contentblock.py index 0d0b371e..fda65367 100644 --- a/server/books/schema/mutations/contentblock.py +++ b/server/books/schema/mutations/contentblock.py @@ -10,7 +10,7 @@ from books.models import ContentBlock, Chapter, SchoolClass from books.schema.inputs import ContentBlockInput from ..nodes import ContentBlockNode from core.utils import set_hidden_for, set_visible_for -from .utils import handle_content_block, set_user_defined_block_type +from .utils import handle_content_block, handle_text, set_user_defined_block_type class MutateContentBlock(relay.ClientIDMutation): diff --git a/server/books/schema/mutations/utils.py b/server/books/schema/mutations/utils.py index 87bb708e..71a6db84 100644 --- a/server/books/schema/mutations/utils.py +++ b/server/books/schema/mutations/utils.py @@ -20,10 +20,15 @@ class AssignmentParameterException(Exception): pass -def newlines_to_paragraphs(text): - parts = re.split(r'[\r\n]+', text) - paragraphs = ['
{}
'.format(p.strip()) for p in parts] - return '\n'.join(paragraphs) +def handle_text(text): + is_list = bool(re.search(r'{}
'.format(p.strip()) for p in parts] + return '\n'.join(paragraphs) ALLOWED_BLOCKS = ( @@ -49,7 +54,7 @@ def handle_content_block(content, context=None, module=None, allowed_blocks=ALLO return { 'type': 'text_block', 'value': { - 'text': newlines_to_paragraphs(bleach.clean(content['value']['text'], strip=True)) + 'text': handle_text(bleach.clean(content['value']['text'], strip=True)) }} elif content['type'] == 'assignment': if module is None: