We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Markdown messes with Gender Mainstreaming
When writing “Initiator*innen […] Entscheidungsträger*innen” in a comment, the text between the `*` is set in italics, because of the markdown formatting, I assume. Is there anything we can do about that?  If I remember it correctly, some version of markdown only allows underscores for emphasis and double “*” for setting something in bold. Should we maybe use that version?

![bildschirmfoto 2016-11-21 um 12 22 31](https://cloud.githubusercontent.com/assets/15341015/20481129/e73970dc-afe5-11e6-8189-2210fc0b6c17.png)

Example here: https://opin-stage.liqd.net/de/projects/opin-alleinstellungsmerkmale-fur-produktseite/
Markdown in comments in consistent with rest
We decided against Markdown in most of the other input fields and used CKEditor instead, but comments still use markdown. But this is not document anywhere. So these are our options:
1. support markdown in comments, but also advertise it to the user
2. support only new lines and nor further formatting in comments (like _italic_, **bold**, ~~strike~~)
3. add ckeditor to comment edit field and allow some basic html in comments


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `euth/comments/templatetags/react_comments.py`
Content:
```
1 import json
2 
3 from django import template, utils
4 from django.contrib.contenttypes.models import ContentType
5 from django.utils.safestring import mark_safe
6 
7 
8 from ..models import Comment
9 from ..serializers import ThreadSerializer
10 
11 register = template.Library()
12 
13 
14 @register.simple_tag(takes_context=True)
15 def react_comments(context, obj):
16     request = context['request']
17 
18     serializer = ThreadSerializer(
19         obj.comments.all(), many=True, context={'request': request})
20     comments = serializer.data
21 
22     user = request.user
23     is_authenticated = user.is_authenticated()
24     is_moderator = user.is_superuser or user in obj.project.moderators.all()
25     user_name = user.username
26 
27     contenttype = ContentType.objects.get_for_model(obj)
28     permission = '{ct.app_label}.comment_{ct.model}'.format(ct=contenttype)
29     has_comment_permission = user.has_perm(permission, obj)
30 
31     comments_contenttype = ContentType.objects.get_for_model(Comment)
32     pk = obj.pk
33 
34     language = utils.translation.get_language()
35 
36     mountpoint = 'comments_for_{contenttype}_{pk}'.format(
37         contenttype=contenttype.pk,
38         pk=pk
39     )
40     attributes = {
41         'comments': comments,
42         'comments_contenttype': comments_contenttype.pk,
43         'subjectType': contenttype.pk,
44         'subjectId': pk,
45         'isAuthenticated': is_authenticated,
46         'isModerator': is_moderator,
47         'user_name': user_name,
48         'language': language,
49         'isReadOnly': not has_comment_permission,
50     }
51 
52     return mark_safe((
53         '<div id={mountpoint}></div><script>window.opin.renderComment('
54         '{mountpoint}, {attributes})</script>').format(
55             attributes=json.dumps(attributes),
56             mountpoint=json.dumps(mountpoint)
57     )
58     )
59
```

Path: `euth/comments/models.py`
Content:
```
1 from django.conf import settings
2 from django.contrib.contenttypes.fields import (GenericForeignKey,
3                                                 GenericRelation)
4 from django.contrib.contenttypes.models import ContentType
5 from django.db import models
6 from django.utils.translation import ugettext_lazy as _
7 
8 from euth.contrib.base_models import UserGeneratedContentModel
9 from euth.contrib.generics import models_to_limit
10 from euth.ratings import models as rating_models
11 
12 
13 class Comment(UserGeneratedContentModel):
14 
15     content_type = models.ForeignKey(
16         ContentType,
17         on_delete=models.CASCADE,
18         limit_choices_to=models_to_limit(settings.COMMENTABLES)
19     )
20     object_pk = models.PositiveIntegerField()
21     content_object = GenericForeignKey(
22         ct_field="content_type", fk_field="object_pk")
23     comment = models.TextField(max_length=1024)
24     is_removed = models.BooleanField(default=False)
25     is_censored = models.BooleanField(default=False)
26     ratings = GenericRelation(rating_models.Rating,
27                               related_query_name='comment',
28                               object_id_field='object_pk')
29     child_comments = GenericRelation('self',
30                                      related_query_name='parent_comment',
31                                      object_id_field='object_pk')
32 
33     class Meta:
34         verbose_name = _("Comment")
35         verbose_name_plural = _("Comments")
36         ordering = ('created',)
37 
38     def __str__(self):
39         if len(self.comment) > 50:
40             return "comment: {} ...".format(self.comment[:50])
41         else:
42             return "comment: {}".format(self.comment)
43 
44     def save(self, *args, **kwargs):
45         """
46         Change the text of the comment if
47         the comment was marked removed or censored
48         """
49 
50         if self.is_removed:
51             self.comment = 'deleted by creator'
52         if self.is_censored:
53             self.comment = 'deleted by moderator'
54         return super(Comment, self).save(*args, **kwargs)
55 
56     def get_absolute_url(self):
57         if hasattr(self.content_object, 'get_absolute_url'):
58             return self.content_object.get_absolute_url()
59         elif hasattr(self.project, 'get_absolute_url'):
60             return self.project.get_absolute_url()
61         else:
62             return None
63 
64     @property
65     def notification_content(self):
66         return self.comment
67 
68     @property
69     def project(self):
70         co = self.content_object
71         if isinstance(co, self.__class__):
72             co = co.content_object
73         return co.project
74
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/euth/comments/models.py b/euth/comments/models.py
--- a/euth/comments/models.py
+++ b/euth/comments/models.py
@@ -5,6 +5,7 @@
 from django.db import models
 from django.utils.translation import ugettext_lazy as _
 
+from contrib.transforms import html_transforms
 from euth.contrib.base_models import UserGeneratedContentModel
 from euth.contrib.generics import models_to_limit
 from euth.ratings import models as rating_models
@@ -47,6 +48,9 @@
         the comment was marked removed or censored
         """
 
+        self.comment = html_transforms.clean_html_all(
+            self.comment)
+
         if self.is_removed:
             self.comment = 'deleted by creator'
         if self.is_censored:
diff --git a/euth/comments/templatetags/react_comments.py b/euth/comments/templatetags/react_comments.py
--- a/euth/comments/templatetags/react_comments.py
+++ b/euth/comments/templatetags/react_comments.py
@@ -16,7 +16,8 @@
     request = context['request']
 
     serializer = ThreadSerializer(
-        obj.comments.all(), many=True, context={'request': request})
+        obj.comments.all().order_by('-created'),
+        many=True, context={'request': request})
     comments = serializer.data
 
     user = request.user

{"golden_diff": "diff --git a/euth/comments/models.py b/euth/comments/models.py\n--- a/euth/comments/models.py\n+++ b/euth/comments/models.py\n@@ -5,6 +5,7 @@\n from django.db import models\n from django.utils.translation import ugettext_lazy as _\n \n+from contrib.transforms import html_transforms\n from euth.contrib.base_models import UserGeneratedContentModel\n from euth.contrib.generics import models_to_limit\n from euth.ratings import models as rating_models\n@@ -47,6 +48,9 @@\n         the comment was marked removed or censored\n         \"\"\"\n \n+        self.comment = html_transforms.clean_html_all(\n+            self.comment)\n+\n         if self.is_removed:\n             self.comment = 'deleted by creator'\n         if self.is_censored:\ndiff --git a/euth/comments/templatetags/react_comments.py b/euth/comments/templatetags/react_comments.py\n--- a/euth/comments/templatetags/react_comments.py\n+++ b/euth/comments/templatetags/react_comments.py\n@@ -16,7 +16,8 @@\n     request = context['request']\n \n     serializer = ThreadSerializer(\n-        obj.comments.all(), many=True, context={'request': request})\n+        obj.comments.all().order_by('-created'),\n+        many=True, context={'request': request})\n     comments = serializer.data\n \n     user = request.user\n", "issue": "Markdown messes with Gender Mainstreaming\nWhen writing \u201cInitiator*innen [\u2026] Entscheidungstr\u00e4ger*innen\u201d in a comment, the text between the `*` is set in italics, because of the markdown formatting, I assume. Is there anything we can do about that?  If I remember it correctly, some version of markdown only allows underscores for emphasis and double \u201c*\u201d for setting something in bold. Should we maybe use that version?\r\n\r\n![bildschirmfoto 2016-11-21 um 12 22 31](https://cloud.githubusercontent.com/assets/15341015/20481129/e73970dc-afe5-11e6-8189-2210fc0b6c17.png)\r\n\r\nExample here: https://opin-stage.liqd.net/de/projects/opin-alleinstellungsmerkmale-fur-produktseite/\nMarkdown in comments in consistent with rest\nWe decided against Markdown in most of the other input fields and used CKEditor instead, but comments still use markdown. But this is not document anywhere. So these are our options:\n1. support markdown in comments, but also advertise it to the user\n2. support only new lines and nor further formatting in comments (like _italic_, **bold**, ~~strike~~)\n3. add ckeditor to comment edit field and allow some basic html in comments\n\n", "before_files": [{"content": "import json\n\nfrom django import template, utils\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.utils.safestring import mark_safe\n\n\nfrom ..models import Comment\nfrom ..serializers import ThreadSerializer\n\nregister = template.Library()\n\n\n@register.simple_tag(takes_context=True)\ndef react_comments(context, obj):\n    request = context['request']\n\n    serializer = ThreadSerializer(\n        obj.comments.all(), many=True, context={'request': request})\n    comments = serializer.data\n\n    user = request.user\n    is_authenticated = user.is_authenticated()\n    is_moderator = user.is_superuser or user in obj.project.moderators.all()\n    user_name = user.username\n\n    contenttype = ContentType.objects.get_for_model(obj)\n    permission = '{ct.app_label}.comment_{ct.model}'.format(ct=contenttype)\n    has_comment_permission = user.has_perm(permission, obj)\n\n    comments_contenttype = ContentType.objects.get_for_model(Comment)\n    pk = obj.pk\n\n    language = utils.translation.get_language()\n\n    mountpoint = 'comments_for_{contenttype}_{pk}'.format(\n        contenttype=contenttype.pk,\n        pk=pk\n    )\n    attributes = {\n        'comments': comments,\n        'comments_contenttype': comments_contenttype.pk,\n        'subjectType': contenttype.pk,\n        'subjectId': pk,\n        'isAuthenticated': is_authenticated,\n        'isModerator': is_moderator,\n        'user_name': user_name,\n        'language': language,\n        'isReadOnly': not has_comment_permission,\n    }\n\n    return mark_safe((\n        '<div id={mountpoint}></div><script>window.opin.renderComment('\n        '{mountpoint}, {attributes})</script>').format(\n            attributes=json.dumps(attributes),\n            mountpoint=json.dumps(mountpoint)\n    )\n    )\n", "path": "euth/comments/templatetags/react_comments.py"}, {"content": "from django.conf import settings\nfrom django.contrib.contenttypes.fields import (GenericForeignKey,\n                                                GenericRelation)\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.db import models\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom euth.contrib.base_models import UserGeneratedContentModel\nfrom euth.contrib.generics import models_to_limit\nfrom euth.ratings import models as rating_models\n\n\nclass Comment(UserGeneratedContentModel):\n\n    content_type = models.ForeignKey(\n        ContentType,\n        on_delete=models.CASCADE,\n        limit_choices_to=models_to_limit(settings.COMMENTABLES)\n    )\n    object_pk = models.PositiveIntegerField()\n    content_object = GenericForeignKey(\n        ct_field=\"content_type\", fk_field=\"object_pk\")\n    comment = models.TextField(max_length=1024)\n    is_removed = models.BooleanField(default=False)\n    is_censored = models.BooleanField(default=False)\n    ratings = GenericRelation(rating_models.Rating,\n                              related_query_name='comment',\n                              object_id_field='object_pk')\n    child_comments = GenericRelation('self',\n                                     related_query_name='parent_comment',\n                                     object_id_field='object_pk')\n\n    class Meta:\n        verbose_name = _(\"Comment\")\n        verbose_name_plural = _(\"Comments\")\n        ordering = ('created',)\n\n    def __str__(self):\n        if len(self.comment) > 50:\n            return \"comment: {} ...\".format(self.comment[:50])\n        else:\n            return \"comment: {}\".format(self.comment)\n\n    def save(self, *args, **kwargs):\n        \"\"\"\n        Change the text of the comment if\n        the comment was marked removed or censored\n        \"\"\"\n\n        if self.is_removed:\n            self.comment = 'deleted by creator'\n        if self.is_censored:\n            self.comment = 'deleted by moderator'\n        return super(Comment, self).save(*args, **kwargs)\n\n    def get_absolute_url(self):\n        if hasattr(self.content_object, 'get_absolute_url'):\n            return self.content_object.get_absolute_url()\n        elif hasattr(self.project, 'get_absolute_url'):\n            return self.project.get_absolute_url()\n        else:\n            return None\n\n    @property\n    def notification_content(self):\n        return self.comment\n\n    @property\n    def project(self):\n        co = self.content_object\n        if isinstance(co, self.__class__):\n            co = co.content_object\n        return co.project\n", "path": "euth/comments/models.py"}], "after_files": [{"content": "import json\n\nfrom django import template, utils\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.utils.safestring import mark_safe\n\n\nfrom ..models import Comment\nfrom ..serializers import ThreadSerializer\n\nregister = template.Library()\n\n\n@register.simple_tag(takes_context=True)\ndef react_comments(context, obj):\n    request = context['request']\n\n    serializer = ThreadSerializer(\n        obj.comments.all().order_by('-created'),\n        many=True, context={'request': request})\n    comments = serializer.data\n\n    user = request.user\n    is_authenticated = user.is_authenticated()\n    is_moderator = user.is_superuser or user in obj.project.moderators.all()\n    user_name = user.username\n\n    contenttype = ContentType.objects.get_for_model(obj)\n    permission = '{ct.app_label}.comment_{ct.model}'.format(ct=contenttype)\n    has_comment_permission = user.has_perm(permission, obj)\n\n    comments_contenttype = ContentType.objects.get_for_model(Comment)\n    pk = obj.pk\n\n    language = utils.translation.get_language()\n\n    mountpoint = 'comments_for_{contenttype}_{pk}'.format(\n        contenttype=contenttype.pk,\n        pk=pk\n    )\n    attributes = {\n        'comments': comments,\n        'comments_contenttype': comments_contenttype.pk,\n        'subjectType': contenttype.pk,\n        'subjectId': pk,\n        'isAuthenticated': is_authenticated,\n        'isModerator': is_moderator,\n        'user_name': user_name,\n        'language': language,\n        'isReadOnly': not has_comment_permission,\n    }\n\n    return mark_safe((\n        '<div id={mountpoint}></div><script>window.opin.renderComment('\n        '{mountpoint}, {attributes})</script>').format(\n            attributes=json.dumps(attributes),\n            mountpoint=json.dumps(mountpoint)\n    )\n    )\n", "path": "euth/comments/templatetags/react_comments.py"}, {"content": "from django.conf import settings\nfrom django.contrib.contenttypes.fields import (GenericForeignKey,\n                                                GenericRelation)\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.db import models\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom contrib.transforms import html_transforms\nfrom euth.contrib.base_models import UserGeneratedContentModel\nfrom euth.contrib.generics import models_to_limit\nfrom euth.ratings import models as rating_models\n\n\nclass Comment(UserGeneratedContentModel):\n\n    content_type = models.ForeignKey(\n        ContentType,\n        on_delete=models.CASCADE,\n        limit_choices_to=models_to_limit(settings.COMMENTABLES)\n    )\n    object_pk = models.PositiveIntegerField()\n    content_object = GenericForeignKey(\n        ct_field=\"content_type\", fk_field=\"object_pk\")\n    comment = models.TextField(max_length=1024)\n    is_removed = models.BooleanField(default=False)\n    is_censored = models.BooleanField(default=False)\n    ratings = GenericRelation(rating_models.Rating,\n                              related_query_name='comment',\n                              object_id_field='object_pk')\n    child_comments = GenericRelation('self',\n                                     related_query_name='parent_comment',\n                                     object_id_field='object_pk')\n\n    class Meta:\n        verbose_name = _(\"Comment\")\n        verbose_name_plural = _(\"Comments\")\n        ordering = ('created',)\n\n    def __str__(self):\n        if len(self.comment) > 50:\n            return \"comment: {} ...\".format(self.comment[:50])\n        else:\n            return \"comment: {}\".format(self.comment)\n\n    def save(self, *args, **kwargs):\n        \"\"\"\n        Change the text of the comment if\n        the comment was marked removed or censored\n        \"\"\"\n\n        self.comment = html_transforms.clean_html_all(\n            self.comment)\n\n        if self.is_removed:\n            self.comment = 'deleted by creator'\n        if self.is_censored:\n            self.comment = 'deleted by moderator'\n        return super(Comment, self).save(*args, **kwargs)\n\n    def get_absolute_url(self):\n        if hasattr(self.content_object, 'get_absolute_url'):\n            return self.content_object.get_absolute_url()\n        elif hasattr(self.project, 'get_absolute_url'):\n            return self.project.get_absolute_url()\n        else:\n            return None\n\n    @property\n    def notification_content(self):\n        return self.comment\n\n    @property\n    def project(self):\n        co = self.content_object\n        if isinstance(co, self.__class__):\n            co = co.content_object\n        return co.project\n", "path": "euth/comments/models.py"}]}