# Path: textplusstuff/exceptions.py
# class InvalidRenderOption(Exception):
#     pass
# 
# class NotRegistered(Exception):
#     pass
# 
# class MissingRendition(Exception):
#     pass
# 
# Path: textplusstuff/registry.py
# class Rendition(object):
# class Stuff(object):
# class ModelStuff(Stuff):
#         class ListSerializer(ModelSerializer):
#             class Meta:
# class StuffRegistry(object):
#         class ListStuffGroups(TextPlusStuffAPIViewMixIn, APIView):
#     def __init__(self, short_name, verbose_name, description,
#                  path_to_template, rendition_type='block'):
#     def get_context_data(self, **context):
#     def render_as_html(self, context):
#     def __init__(self, model):
#     def _verify_rendition(self, rendition):
#     def _verify_rendition_list_uniqueness(self, rendition_list):
#     def _verify_and_build_initial_rendition_dict(self):
#     def register_non_core_rendition(self, rendition):
#     def get_list_serializer(self):
#     def list_view(self):
#     def detail_view(self):
#     def get_url_name_key(self):
#     def get_urls(self):
#     def __init__(self, name='stuff_registry'):
#     def verify_stuff_cls(self, stuff_cls):
#     def verify_groups(self, groups, stuff_cls):
#     def add_modelstuff(self, model, stuff_cls, groups=[]):
#     def add_noncore_modelstuff_rendition(self, model, rendition):
#     def remove_modelstuff(self, model):
#     def index(self):
#             def prepare_stuffgroups(self):
#             def get_generated_stuffgroups(self):
#             def get(self, request, format=None):
#     def get_urls(self):
#     def urls(self):
# def get_modelstuff_renditions(model_instance):


from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import force_str
from bs4 import BeautifulSoup
from markdown2 import Markdown
from ..exceptions import InvalidRenderOption, NotRegistered, MissingRendition
from ..registry import stuff_registry
        return force_str(
            "<MarkdownFlavoredTextNode: \'{}\'>".format(self.payload[:25]),
            'ascii',
            errors='replace'
        ).replace('\n', '')

    def render(self, render_as):
        """
        `render_as` can be one of three values:
            * 'html': Returns a block of markdown flavored text as HTML
            * 'plain_text': Returns a block of text with markdown syntax
                            removed
            * 'markdown': Returns the text as is.
        """
        if render_as in ['html', 'plain_text']:
            markdowner = Markdown()
            payload = self.payload.encode(
                'ascii',
                'xmlcharrefreplace'
            )
            markdown_as_html = markdowner.convert(payload)
            if render_as == 'html':
                to_return = markdown_as_html
            else:
                to_return = ''.join(
                    BeautifulSoup(markdown_as_html).findAll(text=True)
                )
        elif render_as == 'markdown':
            to_return = self.payload
        else:

# Path: textplusstuff/exceptions.py
# class InvalidRenderOption(Exception):
#     pass
# 
# class NotRegistered(Exception):
#     pass
# 
# class MissingRendition(Exception):
#     pass
# 
# Path: textplusstuff/registry.py
# class Rendition(object):
# class Stuff(object):
# class ModelStuff(Stuff):
#         class ListSerializer(ModelSerializer):
#             class Meta:
# class StuffRegistry(object):
#         class ListStuffGroups(TextPlusStuffAPIViewMixIn, APIView):
#     def __init__(self, short_name, verbose_name, description,
#                  path_to_template, rendition_type='block'):
#     def get_context_data(self, **context):
#     def render_as_html(self, context):
#     def __init__(self, model):
#     def _verify_rendition(self, rendition):
#     def _verify_rendition_list_uniqueness(self, rendition_list):
#     def _verify_and_build_initial_rendition_dict(self):
#     def register_non_core_rendition(self, rendition):
#     def get_list_serializer(self):
#     def list_view(self):
#     def detail_view(self):
#     def get_url_name_key(self):
#     def get_urls(self):
#     def __init__(self, name='stuff_registry'):
#     def verify_stuff_cls(self, stuff_cls):
#     def verify_groups(self, groups, stuff_cls):
#     def add_modelstuff(self, model, stuff_cls, groups=[]):
#     def add_noncore_modelstuff_rendition(self, model, rendition):
#     def remove_modelstuff(self, model):
#     def index(self):
#             def prepare_stuffgroups(self):
#             def get_generated_stuffgroups(self):
#             def get(self, request, format=None):
#     def get_urls(self):
#     def urls(self):
# def get_modelstuff_renditions(model_instance):


# Path: textplusstuff/parser/nodes.py
from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import force_str
from bs4 import BeautifulSoup
from markdown2 import Markdown
from ..exceptions import InvalidRenderOption, NotRegistered, MissingRendition
from ..registry import stuff_registry

        return force_str(
            "<MarkdownFlavoredTextNode: \'{}\'>".format(self.payload[:25]),
            'ascii',
            errors='replace'
        ).replace('\n', '')

    def render(self, render_as):
        """
        `render_as` can be one of three values:
            * 'html': Returns a block of markdown flavored text as HTML
            * 'plain_text': Returns a block of text with markdown syntax
                            removed
            * 'markdown': Returns the text as is.
        """
        if render_as in ['html', 'plain_text']:
            markdowner = Markdown()
            payload = self.payload.encode(
                'ascii',
                'xmlcharrefreplace'
            )
            markdown_as_html = markdowner.convert(payload)
            if render_as == 'html':
                to_return = markdown_as_html
            else:
                to_return = ''.join(
                    BeautifulSoup(markdown_as_html).findAll(text=True)
                )
        elif render_as == 'markdown':
            to_return = self.payload
        else:

            raise InvalidRenderOption(