mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Improved MD support.
Add some styling for images in MD Add support for the bastardisation of the MD html for RML.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -137,3 +137,9 @@ textarea {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
.markdown {
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
<dd> </dd>
|
||||
|
||||
<dt>Event Description</dt>
|
||||
<dd>{{ event.description|markdown }}</dd>
|
||||
<dd>{{ event.description|markdown:'rml' }}</dd>
|
||||
|
||||
<dd> </dd>
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{% load markdown_tags %}
|
||||
|
||||
<setNextFrame name="main"/>
|
||||
<nextFrame/>
|
||||
|
||||
@@ -15,9 +17,7 @@
|
||||
</para>
|
||||
|
||||
<keepInFrame>
|
||||
<para style="style.event_description">
|
||||
{{ object.description|default_if_none:""|linebreaksbr }}
|
||||
</para>
|
||||
{{ object.description|default_if_none:""|markdown:'rml' }}
|
||||
</keepInFrame>
|
||||
|
||||
{% if invoice %}
|
||||
@@ -173,9 +173,9 @@
|
||||
<para>{{ item.name }}
|
||||
{% if item.description %}
|
||||
</para>
|
||||
<para style="item_description">
|
||||
<em>{{ item.description|linebreaksbr }}</em>
|
||||
</para>
|
||||
<indent left="1cm">
|
||||
{{ item.description|markdown:"rml" }}
|
||||
</indent>
|
||||
<para>
|
||||
{% endif %}
|
||||
</para>
|
||||
@@ -315,4 +315,4 @@
|
||||
{% include "RIGS/event_print_signature.xml" %}
|
||||
</keepTogether>
|
||||
{% endif %}
|
||||
<namedString id="lastPage"><pageNumber/></namedString>
|
||||
<namedString id="lastPage"><pageNumber/></namedString>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from django import template
|
||||
from django.utils.safestring import mark_safe
|
||||
import markdown
|
||||
@@ -7,5 +8,32 @@ __author__ = 'ghost'
|
||||
register = template.Library()
|
||||
|
||||
@register.filter(name="markdown")
|
||||
def markdown_filter(text):
|
||||
return mark_safe(markdown.markdown(text))
|
||||
def markdown_filter(text, format='html'):
|
||||
html = markdown.markdown(text)
|
||||
if format == 'html':
|
||||
return mark_safe('<div class="markdown">' + html + '</div>')
|
||||
elif format == 'rml':
|
||||
# Convert format to RML
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
|
||||
# Image aren't supported so remove them
|
||||
for img in soup('img'):
|
||||
img.parent.extract()
|
||||
|
||||
# <code> should become <pre>
|
||||
for c in soup('code'):
|
||||
c.name = 'pre'
|
||||
c.parent.replaceWithChildren()
|
||||
|
||||
# blockquotes don't exist but we can still do something to show
|
||||
for bq in soup('blockquote'):
|
||||
bq.name = 'pre'
|
||||
bq.string = bq.text
|
||||
|
||||
# Paragraphs have a different tag
|
||||
for p in soup('p'):
|
||||
p.name = 'para'
|
||||
|
||||
# @todo: <ul> and <li> tags to not appear to be working
|
||||
|
||||
return mark_safe(soup)
|
||||
|
||||
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
@@ -1,3 +1,4 @@
|
||||
beautifulsoup4==4.4.1
|
||||
dj-database-url==0.3.0
|
||||
dj-static==0.0.6
|
||||
Django==1.8.2
|
||||
|
||||
Reference in New Issue
Block a user