mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-04-07 11:11:46 +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>
|
<dd> </dd>
|
||||||
|
|
||||||
<dt>Event Description</dt>
|
<dt>Event Description</dt>
|
||||||
<dd>{{ event.description|markdown }}</dd>
|
<dd>{{ event.description|markdown:'rml' }}</dd>
|
||||||
|
|
||||||
<dd> </dd>
|
<dd> </dd>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
{% load markdown_tags %}
|
||||||
|
|
||||||
<setNextFrame name="main"/>
|
<setNextFrame name="main"/>
|
||||||
<nextFrame/>
|
<nextFrame/>
|
||||||
|
|
||||||
@@ -15,9 +17,7 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<keepInFrame>
|
<keepInFrame>
|
||||||
<para style="style.event_description">
|
{{ object.description|default_if_none:""|markdown:'rml' }}
|
||||||
{{ object.description|default_if_none:""|linebreaksbr }}
|
|
||||||
</para>
|
|
||||||
</keepInFrame>
|
</keepInFrame>
|
||||||
|
|
||||||
{% if invoice %}
|
{% if invoice %}
|
||||||
@@ -173,9 +173,9 @@
|
|||||||
<para>{{ item.name }}
|
<para>{{ item.name }}
|
||||||
{% if item.description %}
|
{% if item.description %}
|
||||||
</para>
|
</para>
|
||||||
<para style="item_description">
|
<indent left="1cm">
|
||||||
<em>{{ item.description|linebreaksbr }}</em>
|
{{ item.description|markdown:"rml" }}
|
||||||
</para>
|
</indent>
|
||||||
<para>
|
<para>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</para>
|
</para>
|
||||||
@@ -315,4 +315,4 @@
|
|||||||
{% include "RIGS/event_print_signature.xml" %}
|
{% include "RIGS/event_print_signature.xml" %}
|
||||||
</keepTogether>
|
</keepTogether>
|
||||||
{% endif %}
|
{% 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 import template
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
import markdown
|
import markdown
|
||||||
@@ -7,5 +8,32 @@ __author__ = 'ghost'
|
|||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@register.filter(name="markdown")
|
@register.filter(name="markdown")
|
||||||
def markdown_filter(text):
|
def markdown_filter(text, format='html'):
|
||||||
return mark_safe(markdown.markdown(text))
|
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-database-url==0.3.0
|
||||||
dj-static==0.0.6
|
dj-static==0.0.6
|
||||||
Django==1.8.2
|
Django==1.8.2
|
||||||
|
|||||||
Reference in New Issue
Block a user