X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/d6d07b7e85c360fe7ea047d3bc80b8769c90e660..bfdf1fb55d9a5ee7be5a16ef73e6237ad949ddcb:/librarian/pyhtml.py diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index d868a17..6d1e914 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -9,6 +9,7 @@ from xmlutils import Xmill, tag, tagged, ifoption, tag_open_close from librarian import functions import re import random +from copy import deepcopy IMAGE_THUMB_WIDTH = 300 @@ -66,11 +67,12 @@ class EduModule(Xmill): toc.append("
  • %s
  • " % atxt) toc = "" % "".join(toc) add_header = "Lekcja: " if self.options['wldoc'].book_info.type in ('course', 'synthetic') else '' - return "

    %s" % add_header, "

    " + toc + return "

    %s" % add_header, "

    " + toc - @tagged("h2") def handle_naglowek_rozdzial(self, element): - return "", "".join(tag_open_close("a", name=self.naglowek_to_anchor(element))) + return_to_top = u"wróć do spisu treści" + anchor = "".join(tag_open_close("a", name=self.naglowek_to_anchor(element))) + return return_to_top + "

    ", anchor + "

    " def handle_uwaga(self, _e): return None @@ -361,14 +363,16 @@ class Exercise(EduModule): def get_instruction(self): if not self.instruction_printed: self.instruction_printed = True - return u'%s' % self.INSTRUCTION + if self.INSTRUCTION: + return u'%s' % self.INSTRUCTION + else: + return "" else: return "" class Wybor(Exercise): - INSTRUCTION = None def handle_cwiczenie(self, element): pre, post = super(Wybor, self).handle_cwiczenie(element) is_single_choice = True @@ -441,12 +445,10 @@ class Luki(Exercise): return question.xpath(".//luka") def solution_html(self, piece): + piece = deepcopy(piece) + piece.tail = None sub = EduModule() return sub.generate(piece) - # print piece.text - # return piece.text + ''.join( - # [etree.tostring(n, encoding=unicode) - # for n in piece]) def handle_pytanie(self, element): qpre, qpost = super(Luki, self).handle_pytanie(element)