Esempio n. 1
0
    def test_markdown(self):

        for test in TEST_CASES:
            given, expected = test

            html = markdown.parse(given, clean=True, escape=False)
            html = html.replace("\n", "")
            self.assertEqual(html, expected, f"Error with markdown parsing. input={given}, expected={expected}, html={html}")
Esempio n. 2
0
    def save(self, *args, **kwargs):

        # Needs to be imported here to avoid circular imports.
        from network.forum import markdown

        self.creation_date = self.creation_date or util.now()
        self.uid = self.uid or util.get_uuid(limit=16)
        self.institution = self.institution
        self.external_link = self.external_link

        # Sanitize the job body.
        self.html = markdown.parse(self.content,
                                   job=self,
                                   clean=True,
                                   escape=False)

        # This will trigger the signals
        super(Job, self).save(*args, **kwargs)
Esempio n. 3
0
    def handle(self, *args, **options):

        # import markdown2
        # import bleach
        # html_classes = dict(code="language-bash", pre="pre")
        # html1 = markdown2.markdown(test5,
        #                            extras={"fenced-code-blocks": {},
        #                                   "code-friendly": {}, "nofollow": {}, "spoiler": {},
        #                                   "html-classes": html_classes})
        # html1 = bleach.clean(html1, tags=['p', 'b'])
        # print(html1)
        # print('MISTUNE', '-'*50)

        # escape = False to allow html in the markdown.
        html = markdown.parse(test5,
                              escape=False,
                              clean=True,
                              allow_rewrite=False)
        print()
        print(html)
Esempio n. 4
0
    def save(self, *args, **kwargs):

        # Needs to be imported here to avoid circular imports.
        from network.forum import markdown

        self.lastedit_user = self.lastedit_user or self.author
        self.creation_date = self.creation_date or util.now()
        self.uid = self.uid or util.get_uuid(limit=16)
        self.location = self.location
        self.external_link = self.external_link

        # Sanitize the event body.
        self.html = markdown.parse(self.content,
                                   event=self,
                                   clean=True,
                                   escape=False)
        self.tag_val = self.tag_val.replace(' ', '')
        # Default tags
        self.tag_val = self.tag_val or "workshop, tutorial,"

        # This will trigger the signals
        super(Event, self).save(*args, **kwargs)
Esempio n. 5
0
    def save(self, *args, **kwargs):

        # Needs to be imported here to avoid circular imports.
        from network.forum import markdown

        self.lastedit_user = self.lastedit_user or self.author

        self.creation_date = self.creation_date or util.now()
        self.lastedit_date = self.lastedit_date or util.now()
        self.last_contributor = self.lastedit_user

        # Sanitize the post body.
        self.html = markdown.parse(self.content,
                                   post=self,
                                   clean=True,
                                   escape=False)
        self.tag_val = self.tag_val.replace(' ', '')
        # Default tags
        self.tag_val = self.tag_val or "tag1, tag2,"
        # Set the top level state of the post.
        self.is_toplevel = self.type in Post.TOP_LEVEL

        # This will trigger the signals
        super(Post, self).save(*args, **kwargs)