lpschedule-generator

libreplanet schedule generator - ricketyspace.net/lpschedule-generator
git clone git://git.ricketyspace.net/lpschedule-generator.git
Log | Files | Refs

commit 85e437b962b4a22db1e4a87232624fc296622d3a
parent 10a44e832ed22e0f09b945f9b5499b909807c602
Author: jantwisted <janith@member.fsf.org>
Date:   Sun, 29 Nov 2015 00:34:32 +0530

custom html render for mistune

Diffstat:
lpschedule/htmlrender.py | 35+++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+), 0 deletions(-)

diff --git a/lpschedule/htmlrender.py b/lpschedule/htmlrender.py @@ -0,0 +1,34 @@ +import mistune +import re + + +class HtmlRender(mistune.Renderer): + """ + Subclassing Renderer classes to customize HTML content. + + """ + def header(self, text, level, raw=None): + if level == 2: + return '<header class="program-day-header">\n\t<hgroup>\n\t\t<h%d>%s\n\t\t</h%d>\n\t</hgroup>\n</header>\n' % (level, text+ \ + '\n\t\t<a class="btn btn-default btn-xs" \n\t\trole="button" '+ \ + 'data-toggle="collapse" \n\t\taria-expanded="false" '+ \ + 'aria-controls="sat-timeslots" '+ \ + '\n\t\thref="#sat-timeslots">&#x2193;</a>', level) + elif level == 3: + return '\n<article id="sat-ts-b0" class="program-timeslot-break">'+ \ + '\n\t<header class="program-timeslot-break-header">'+ \ + '\n\t\t<hgroup>\n\t\t\t<h%d>%s</h%d>\n\t\t</hgroup>\n\t</header>\n</article>\n' % (level, text, level) + + return '<h%d>%s</h%d>\n' % (level, text, level) + + + def paragraph(self, text): + _get_room_ptr = re.compile(r'(Room\s[\d]*\-[\d]*)') + if _get_room_ptr.search(text.strip(' ')) is not None: + str = _get_room_ptr.findall(text.strip(' ')) + return '<p><span class="label label-default">%s</span></p>\n<a href="#" class="program-session-speaker">%s</a>' \ + % (''.join(str), _get_room_ptr.sub('',text.strip(' '))) + \ + '\n<button class="btn btn-default btn-xs" data-toggle="collapse" \n\taria-expanded="false" aria-controls="sat-ts0-s0-collapse"'+ \ + 'data-target="#sat-ts0-s0-collapse">\n\t\tDetails\n</button>\n' + else: + return '<p>%s</p>\n' % text.strip(' ')+ \ No newline at end of file