Commit ce2b424d authored by Robert's avatar Robert

Write out markdown via html to get proper formatting, refs #386

parent 866bfb40
......@@ -4,7 +4,8 @@ import os
import random
import bleach as python_bleach
import html2text as python_html2text
import markdown as python_markdown
from core import fragments, markdown as core_markdown
from core.views import app_config
from django import apps, template
......@@ -14,7 +15,6 @@ from django.template import defaultfilters
from django.template.base import FilterExpression
from django.template.loader import get_template
from django.utils import html as django_html, safestring
import markdown as python_markdown
from markdown.extensions import toc
from core.assets import get_assets
......@@ -72,6 +72,18 @@ def nolinebreaks(value):
return ' '.join(str(value).split('\n'))
@register.filter
def html2text(html, preset='mail'):
text_maker = python_html2text.HTML2Text()
if preset == 'mail':
text_maker.inline_links = False
text_maker.links_each_paragraph = True
text_maker.use_automatic_links = True
elif preset == 'import':
pass
return text_maker.handle(html).rstrip()
@register.simple_tag(takes_context=True)
def get_parameters(context, **kwargs):
request = context.get('request')
......
{% extends 'content/created.txt' %}{% block content %}Artikel online lesen und kommentieren:
{% url 'content-permalink' association.pk as path %}{{ path|full_url }}
{{ object.versions.last.text }}{% endblock %}
{% markdown object.versions.last.text as html %}{{ html|html2text:'mail' }}{% endblock %}
Beitrag mit Kommentaren online lesen und kommentieren:
{% if association %}{% url 'content-permalink' association.pk as path %}{% else %}{% url 'content-permalink' object.container.associations.first.pk as path %}{% endif %}{{ path|full_url }}#{% ref object %}
{{ text|striptags }}
{% markdown text as html %}{{ html|html2text:'mail' }}
--
{% load rules %}{% has_perm 'contributions.reply_to_author' recipient.user object as can_reply_to_author %}{% if can_reply_to_author %}Nur an {{ object.author }} antworten:
......
{{ text|striptags }}
{% markdown text as html %}{{ html|html2text:'mail' }}
--
Nachricht online lesen und beantworten:
......
......@@ -4,4 +4,4 @@
Veranstaltung {% load events %}{% event_time object %}
Ort: {{ object.place }}
{{ object.versions.last.text }}{% endblock %}
{% markdown object.versions.last.text as html %}{{ html|html2text:'mail' }}{% endblock %}
......@@ -3,4 +3,4 @@
Datei {{ object.versions.last.file.get }}
{{ object.versions.last.text }}{% endblock %}
{% markdown object.versions.last.text as html %}{{ html|html2text:'mail' }}{% endblock %}
......@@ -3,4 +3,4 @@
Galerie mit {{ object.gallery_images.count }} Bild{{ object.gallery_images.count|pluralize:'ern' }}
{{ object.versions.last.text }}{% endblock %}
{% markdown object.versions.last.text as html %}{{ html|html2text:'mail' }}{% endblock %}
{% extends 'content/created.txt' %}{% block content %}Umfrage online ansehen und abstimmen oder kommentieren:
{% url 'content-permalink' association.pk as path %}{{ path|full_url }}
{{ object.versions.last.text }}
{% markdown object.versions.last.text as html %}{{ html|html2text:'mail' }}
Antwortmöglichkeiten der Umfrage:{% for option in object.poll.options.all %}
* {{ option|nolinebreaks }}{% endfor %}{% endblock %}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment