----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<script type="text/javascript"
src='
https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async>
</script>
<style type="text/css">
code {background-color: #ffffff; border: 0px; color: #ad0d0d; }
hr {border-width: 2px 0; line-height: 8px}
.fehler {color: #00bb00;}
</style>
{{def markmin(text):
return(MARKMIN(text,
extra=dict(br=lambda x: BR(),
hr=lambda x: HR(),
img=lambda x: make_img(x),
wav=lambda x: make_wav(x),
html=lambda x: make_html(x),
code_cpp=lambda text: CODE(text,language='cpp').xml(),
code_python=lambda text: CODE(text,language='python').xml(),
code_html=lambda text: CODE(text,language='html').xml(),
code_ly=lambda text: CODE(text,language='ly').xml())))
pass}}
{{def make_html(text):
out = XML(text, sanitize=False, permitted_tags=[pre,b,span],allowed_attributes={'pre':['style'],'span':['style']})
return(out)
pass}}
{{import re}}
{{regex_picture=re.compile(ur'\s*(?P<title>[a-zäöüßA-ZÄÖÜ_0-9]+(\.[a-zA-Z0-9]+)*)\s*(?P<width>[0-9]+)\s*', re.UNICODE)}}
{{regex_text=re.compile(ur'\s*(?P<title>[a-zäöüßA-ZÄÖÜ_0-9]+(\.[a-zA-Z0-9]+)*)\s*', re.UNICODE)}}
{{def make_img(text):
text=regex_picture.match(text)
try:
image = db(db.image.title==text.group('title')).select().first()
out = IMG( _src=URL(c='default', f='download', args=image.image_data), _width=text.group('width'))
except:
try:
out = DIV('Bild '+text.group('title')+' steht nicht zur Verfügung', _class='fehler')
except:
out = DIV('width des Bildes scheint zu fehlen', _class='fehler')
pass
pass
return(out)
pass}}
{{def make_wav(text):
text=regex_text.match(text)
try:
music = db(db.music.title==text.group('title')).select().first()
src = URL(c='default', f='download', args=music.music_data)
out = '<audio src="'+src+'" controls="controls" type="audio/wav" ></audio>'
except:
out = DIV('Audio-Datei '+text.group('title')+' steht nicht zur Verfügung', _class='fehler')
pass
return(out)
pass}}
--------------------------------------------------------------------------------------------------------------------------------------------