~emihalac/mnemosyne-proj/mnemosyne-proj

« back to all changes in this revision

Viewing changes to mnemosyne/mnemosyne/libmnemosyne/renderers/html_css.py

  • Committer: Peter Bienstman
  • Date: 2017-03-01 18:28:52 UTC
  • Revision ID: peter.bienstman@ugent.be-20170301182852-uzlgodwicl505ft1
Option to have single window Q and A.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
        self._css = {} # {card_type.id: render_args: css}
29
29
 
30
30
    def body_css(self, **render_args):
31
 
        return "html, body { margin: 0px; height: 100%;  width: 100%;}\n"
 
31
        css = "html, body { margin: 0px; height: 100%;  width: 100%;}\n"
 
32
        css += "hr { background-color: black; height: 1px; border: 0; }\n"
 
33
        return css
32
34
 
33
35
    def card_type_css(self, card_type, **render_args):
34
36
        # Set aligment of the table (but not the contents within the table).
107
109
        html = ""
108
110
        for fact_key in fact_keys:
109
111
            if fact_key in fact_data and fact_data[fact_key]:
110
 
                line = "<div id=\"%s\" class=\"%s\">%s</div>" % \
 
112
                line = ""
 
113
                if render_args.get("align_top", False):
 
114
                    line +="<br>"
 
115
                line += "<div id=\"%s\" class=\"%s\">%s</div>" % \
111
116
                    (fact_key, fact_key, fact_data[fact_key])
112
117
                # Honour paragraph style also in user-created tables.
113
118
                line = line.replace("<td>",
121
126
 
122
127
    def render(self, fact_data, fact_keys, card_type, **render_args):
123
128
        css = self.css(card_type)
 
129
        valign = "valign=\"top\"" if render_args.get("align_top", False) else ""
124
130
        body = self.body(fact_data, fact_keys, card_type, **render_args)
 
131
 
125
132
        return """
126
133
        <!DOCTYPE html>
127
134
        <html>
133
140
        </head>
134
141
        <body>
135
142
          <table id="mnem1" class="mnem">
136
 
            <tr>
 
143
            <tr %s>
137
144
              <td>%s</td>
138
145
            </tr>
139
146
          </table>
140
147
        </body>
141
 
        </html>""" % (css, body)
 
148
        </html>""" % (css, valign, body)
142
149