コード例 #1
0
 def as_junit_xml(self):
     """
     Return Junit-format XML fragment.
     """
     xml, tag, text = XML().tagtext()
     with tag('testsuite',
              name=self.name,
              hostname=self.hostname,
              time=(self.stop - self.start),
              tests=len(self._testcases),
              timestamp=datetime.fromtimestamp(self.start).isoformat(),
              errors=self.errored,
              failures=self.failed,
              skipped=self.skipped,
     ):
         if self._id is not None:
             xml.attr(id=self._id)
         with tag('properties'):
             for key, value in self._properties.iteritems():
                 xml.stag('property', name=key, value=str(value))
         for testcase in self._testcases:
             if testcase.status is None:
                 with tag('error'):
                     text('Unknown outcome of this step.')
             else:
                 xml.asis(testcase.as_junit_xml())
     return xml.getvalue()
コード例 #2
0
    def to_html(self, metadata, style=None):
        """Method for producing and html string of selected metadata.

    Parameters
    ----------
    metadata : str
      metadata key
    style : str, optional
      css style of metadata tag

    Returns
    -------
    str
      html string containing the metadata

    >>> source = '---metadata authors = ["S. Zaghi","J. Doe"] ---endmetadata'
    >>> meta = Metadata(source)
    >>> meta.to_html(metadata='authors')
    '<span class="metadata">S. Zaghi and J. Doe</span>'
    """
        doc = Doc()
        if metadata == 'logo':
            self.put_logo(doc=doc, style=style)
        else:
            with doc.tag('span', klass='metadata'):
                if style:
                    doc.attr(style=style)
                doc.asis(self.get_value(metadata))
        return doc.getvalue()
コード例 #3
0
def MessagesToHTML(rows, submission_form):
    # format rows into rich text email
    doc, tag, text = Doc().tagtext()
    with tag('html'):
        with tag('h1', ('align', 'center')):
            text('Blockmate Newsletter!')
        with tag('body', ('align', 'center')):
            for row in rows:
                # submitter's name and date
                with tag('h3', id=row['name']):
                    with tag('font', ('color', row['color'].lower())):
                        date = row['timestamp'].split(' ', 1)[0]
                        text(row['name'] + ' on ' + date)
                # submitter's message
                with tag('p', id=row['name']):
                    with tag('font', ('color', row['color'].lower())):
                        text(row['msg'])
                        doc.attr(style="color:" + row['color'].lower() + ';"')
                # submitter's photos
                photo_urls = [x.strip() for x in row['photos'].split(',')]
                for photo in photo_urls:
                    # use uc?export format instead of open
                    url = photo.replace('open?', 'uc?export=view&', 1)
                    with tag('div', id='photo-container'):
                        doc.stag('img', src=url, width=300)
            with tag('p', id='submit_again'):
                reminder = message_text.WHERE_TO_SUBMIT.format(submission_form)
                text(reminder)
    return (doc.getvalue())
コード例 #4
0
def generate_html(log='', n=None):
    doc, tag, text = Doc().tagtext()
    with tag('html'):
        with tag('body'):
            doc.stag('img', src='img.png')
            doc.stag('img', src='lc_50.png')
            doc.stag('br')
            doc.stag('img', src='img_loss.png')
            doc.stag('img', src='loss_100.png')
            doc.stag('br')
            doc.stag('img', src='conv1_weight.png')
            doc.stag('img', src='conv2_weight.png')
            doc.stag('img', src='fc1_weight.png')
            doc.stag('img', src='fc_v_weight.png')
            doc.stag('img', src='fc_var_weight.png')
            doc.stag('br')
            with doc.tag('textarea'):
                doc.attr(rows='20')
                doc.attr(cols='240')
                for l in log:
                    text(l)
            doc.stag('br')
            if n:
                text('Number of node removals since last game: {}'.format(n))
                doc.stag('br')
            text('Last update:' + str(dt.now()))

    return doc.getvalue()
コード例 #5
0
 def as_junit_xml(self):
     xml, tag, text = XML().tagtext()
     with tag('testcase',
              name=self.name,
              time=(self.stop - self.start)):
         if self.classname is not None:
             xml.attr(classname=self.classname)
         if self.assertions is not None:
             xml.attr(assertions=self.assertions)
         with tag('properties'):
             for key, value in self._properties.iteritems():
                 xml.stag('property', name=key, value=str(value))
         if self.status == 'error':
             with tag('error', message=self._msg):
                 text(self._msg)
         elif self.status == 'failure':
             with tag('failure', message=self._msg):
                 text(self._msg)
         elif self.status == 'skipped':
             xml.stag('skipped', message=self._msg)
         if self.stdout is None:
             xml.stag('system-out')
         else:
             with tag('system-out'):
                 text(str(self.stdout))
         if self.stderr is None:
             xml.stag('system-err')
         else:
             with tag('system-err'):
                 text(str(self.stderr))
     return xml.getvalue()
コード例 #6
0
ファイル: metadata.py プロジェクト: noisyoscillator/MaTiSSe
    def custom_to_html(self, match):
        """Convert custom metadata to html stream.

    Parameters
    ----------
    match: re.match object

    Returns
    -------
    str:
      html stream
    """
        doc = Doc()
        with doc.tag('span', klass='metadata'):
            style = None
            if match.group('style'):
                style = str(match.group('style'))
            if style:
                doc.attr(style=style)
                value = re.search(r'value\:(?P<value>.*?)\;', style)
                if value:
                    doc.asis(
                        re.search(r'value\:(?P<value>.*?)\;',
                                  style).group('value'))
        return doc.getvalue()
コード例 #7
0
 def _raw_file(self, name=None):
     """Build up a page for the Raw File view."""
     name = name if name else ''
     name = name.replace('|', '/')
     display_name = self._get_display_name(name)
     if 'path' not in self.page_options:
         body_txt = 'No directory to serve in the config file.'
     else:
         path = os.path.join(self.path, name)
         body = Doc()
         with body.tag('h1'):
             body.text('File: %s' % display_name)
         with body.tag('div'):
             body.attr(klass='navigation')
             body.asis(self._get_navigation_links(path))
         with body.tag('div'):
             body.attr(klass='files')
             if os.path.exists(path):
                 if os.path.isdir(path):
                     body.asis(self._get_dir_listing(path))
                 else:
                     body.asis(self._get_file(path))
         body_txt = body.getvalue()
     flash_messages = self.page_options.get('flash_messages', True)
     return HtmlPage(head=None,
                     body=body_txt,
                     flash_messages=flash_messages).render_template()
コード例 #8
0
ファイル: qqhtml.py プロジェクト: ischurov/qqmbr
    def handle_enumerateable(self, tag):
        """
        Uses tags: label, number, name
        Add tags used manually from enumerateable_envs

        :param tag:
        :return:
        """
        doc, html, text = Doc().tagtext()
        name = tag.name
        env_localname = self.localize(self.enumerateable_envs[name])
        with html("div", klass="env env__" + name):
            if tag.find("label"):
                doc.attr(id=self.label2id(tag._label.value))

            number = tag.get("number", "")
            with html("span", klass="env-title env-title__" + name):
                if tag.find("label"):
                    with html("a", klass="env-title env-title__" + name, href="#" + self.label2id(tag._label.value)):
                        text(join_nonempty(env_localname, number) + ".")
                else:
                    text(join_nonempty(env_localname, number) + ".")

            doc.asis(" " + self.format(tag, blanks_to_pars= True))
        return "<p>"+doc.getvalue()+"</p>\n<p>"
コード例 #9
0
ファイル: web.py プロジェクト: shibei00/tetris_mcts
def generate_html(log='', n=None):
    doc, tag, text = Doc().tagtext()
    with tag('html'):
        with tag('body'):
            doc.stag('img', src='img.png')
            doc.stag('img', src='lc_50.png')
            doc.stag('br')
            doc.stag('img', src='lc_sc_train.png')
            doc.stag('img', src='data_accum.png')
            doc.stag('br')
            doc.stag('img', src='img_loss.png')
            doc.stag('img', src='loss_100.png')
            doc.stag('br')
            for img in sorted(glob.glob('./*_weight.png'),
                              key=os.path.getmtime):
                doc.stag('img', src=img)
            doc.stag('br')
            with doc.tag('textarea'):
                doc.attr(rows='20')
                doc.attr(cols='240')
                for l in log:
                    text(l)
            doc.stag('br')
            if n:
                text('Number of node removals since last game: {}'.format(n))
                doc.stag('br')
            text('Last update:' + str(dt.now()))

    return doc.getvalue()
コード例 #10
0
ファイル: qqhtml.py プロジェクト: ischurov/qqmbr
    def handle_proof(self, tag: QqTag) -> str:
        """
        Uses tags: proof, label, outline, of

        Examples:

            \proof
                Here is the proof

            \proof \of theorem \ref{thm:1}
                Now we pass to proof of theorem \ref{thm:1}

        :param tag:
        :return: HTML of proof
        """
        doc, html, text = Doc().tagtext()
        with html("div", klass="env env__proof"):
            if tag.find("label"):
                doc.attr(id=self.label2id(tag._label.value))
            with html("span", klass="env-title env-title__proof"):
                if tag.exists("outline"):
                    proofline = 'Proof outline'
                else:
                    proofline = 'Proof'
                doc.asis(join_nonempty(self.localize(proofline),
                                       self.format(tag.find("of"), blanks_to_pars=False)).rstrip()+".")
            doc.asis(rstrip_p(" " + self.format(tag, blanks_to_pars=True)))
            doc.asis("<span class='end-of-proof'>&#8718;</span>")
        return doc.getvalue()+"\n<p>"
コード例 #11
0
ファイル: qqhtml.py プロジェクト: ischurov/qqmbr
    def handle_h(self, tag: QqTag) -> str:
        """
        Uses tags: h1, h2, h3, h4, label, number

        Example:

            \h1 This is first header

            \h2 This is the second header \label{sec:second}

        :param tag:
        :return:
        """
        doc, html, text = Doc().tagtext()
        with html(tag.name):
            doc.attr(id=self.tag_id(tag))
            if tag.find("number"):
                with html("span", klass="section__number"):
                    with html("a", href="#"+self.tag_id(tag), klass="section__number"):
                        text(tag._number.value)
            text(self.format(tag, blanks_to_pars=False))
        ret = doc.getvalue()
        if tag.next() and isinstance(tag.next(), str):
            ret += "<p>"
        return doc.getvalue()
コード例 #12
0
ファイル: prettyt2h.py プロジェクト: ischurov/prettyt2h
def environment_begin_end(env, label=None, number=None, optional=None):
    if env == "document":
        return '<html><meta charset="UTF-8">' + mathjax_snipped, "</html>\n"

    doc, tag, text = Doc().tagtext()
    stop_sign = "!!!chahpieXeiDu3zeer3Ki"

    if env == "itemize" or env == "enumerate":
        with tag(list_envs[env]):
            text(stop_sign)
    else:
        with tag("div", klass="env_" + mk_safe_css_ident(env)):
            if label:
                doc.attr(id="label_" + mk_safe_css_ident(label))
            if env in named_envs:
                with tag("span", klass="env__name"):
                    text(named_envs[env])
            text(" ")
            if number:
                with tag("span", klass="env__number"):
                    text(number)
            text(" ")
            if optional:
                with tag("span", klass="env__opt_text"):
                    text(optional)
            text(stop_sign)
    ret = doc.getvalue()
    index = ret.index(stop_sign)
    begin = ret[:index] + "\n"
    end = ret[index + len(stop_sign) :] + "\n"

    return (begin, end)
コード例 #13
0
ファイル: html_utils.py プロジェクト: mehdi-shiba/exprec
def create_tabs(content_by_tab_name, tabs_id):
    doc, tag, text = Doc().tagtext()

    with tag('ul', klass='nav nav-pills', id=tabs_id, role='tablist'):
        is_first_tab = True
        for i, tab_name in enumerate(content_by_tab_name.keys()):
            with tag('li', klass='nav-item'):
                tab_id = '{}--tab-{}'.format(tabs_id, i)

                with tag('a', ('data-toggle', 'pill'),
                         klass='nav-link',
                         href='#' + tab_id,
                         role='tab'):
                    if is_first_tab:
                        doc.attr(klass='nav-link active')
                        is_first_tab = False

                    doc.asis(tab_name)

    with tag('div', klass='tab-content'):
        is_first_tab = True
        for i, content in enumerate(content_by_tab_name.values()):
            tab_id = '{}--tab-{}'.format(tabs_id, i)

            with tag('div', id=tab_id, klass='tab-pane', role='tabpanel'):
                if is_first_tab:
                    doc.attr(klass='tab-pane active')
                    is_first_tab = False

                doc.asis(content)

    return doc.getvalue()
コード例 #14
0
ファイル: metadata.py プロジェクト: nunb/MaTiSSe
  def to_html(self, metadata, style=None):
    """Method for producing and html string of selected metadata.

    Parameters
    ----------
    metadata : str
      metadata key
    style : str, optional
      css style of metadata tag

    Returns
    -------
    str
      html string containing the metadata

    >>> source = '---metadata authors = ["S. Zaghi","J. Doe"] ---endmetadata'
    >>> meta = Metadata(source)
    >>> meta.to_html(metadata='authors')
    '<span class="metadata">S. Zaghi and J. Doe</span>'
    """
    doc = Doc()
    if metadata == 'logo':
      self.put_logo(doc=doc,style=style)
    else:
      with doc.tag('span',klass='metadata'):
        if style:
          doc.attr(style=style)
        doc.asis(self.get_value(metadata))
    return doc.getvalue()
コード例 #15
0
 def _get_dir_listing(self, path):
     """Build an HTML list of the directory contents."""
     all_fnames = [f for f in os.listdir(path) if not f.startswith('.')]
     suffixes = self.page_options.get('suffix_whitelist', '').split(',')
     fnames = []
     for fname in all_fnames:
         for suffix in suffixes:
             if fname.endswith(suffix):
                 fnames.append(fname)
                 break
             elif os.path.isdir(os.path.join(path, fname)):
                 fnames.append(fname + '/')
                 break
     fnames.sort()
     base = self._get_safe_base_path(path)
     links = []
     for name in fnames:
         doc = Doc()
         name = os.path.join(base, name)
         with doc.tag('a'):
             doc.attr(
                 href=url_for('RawFile:get', name=name.replace('/', '|')))
             doc.text(name)
         links.append(doc.getvalue())
     return list_to_html_list(links)
コード例 #16
0
 def _get_top_dir_link():
     """Get a link to the Top Directory of the Raw File view."""
     doc = Doc()
     with doc.tag('a'):
         doc.attr(href=url_for('RawFile:index'))
         doc.text('Top Dir')
     return doc.getvalue()
コード例 #17
0
    def handle_enumerateable(self, tag: QqTag) -> str:
        """
        Uses tags: label, number, name
        Add tags used manually from enumerateable_envs

        :param tag:
        :return:
        """
        doc, html, text = Doc().tagtext()
        name = tag.name
        env_localname = self.localize(self.enumerateable_envs[name])
        with html("div", klass="env env__" + name):
            if tag.find("label"):
                doc.attr(id=self.label2id(tag.label_.value))

            number = tag.get("number", "")
            with html("span", klass="env-title env-title__" + name):
                if tag.find("label"):
                    with html("a",
                              klass="env-title env-title__" + name,
                              href="#" + self.label2id(tag.label_.value)):
                        text(join_nonempty(env_localname, number) + ".")
                else:
                    text(join_nonempty(env_localname, number) + ".")

            doc.asis(" " + self.format(tag, blanks_to_pars=True))
        return "<p>" + doc.getvalue() + "</p>\n<p>"
コード例 #18
0
    def handle_heading(self, tag: QqTag) -> str:
        """
        Uses tags: chapter, section, subsection, subsubsection
        Uses tags: label, number

        Example:

            \chapter This is first heading

            \section This is the second heading \label{sec:second}

        :param tag:
        :return:
        """
        tag_to_hx = {
            'chapter': 'h1',
            'section': 'h2',
            'subsection': 'h3',
            'subsubsection': 'h4'
        }

        doc, html, text = Doc().tagtext()
        with html(tag_to_hx[tag.name]):
            doc.attr(id=self.tag_id(tag))
            if tag.find("number"):
                with html("span", klass="section__number"):
                    with html("a",
                              href="#" + self.tag_id(tag),
                              klass="section__number"):
                        text(tag.number_.value)
            doc.asis(self.format(tag, blanks_to_pars=False))
        ret = doc.getvalue()
        if tag.next() and isinstance(tag.next(), str):
            ret += "<p>"
        return doc.getvalue()
コード例 #19
0
    def _write_html(file_name, map_name, match_half1, match_half2, spectators,
                    team1_players, team2_players, team1_total_score,
                    team2_total_score, team1_tick_score, team2_tick_score):

        doc, tag, text = Doc().tagtext()

        with tag("html"):
            with tag("head"):
                with tag("style"):
                    doc.asis(styles)

            with tag("body"):
                with tag("center"):
                    with tag("div"):
                        doc.attr(klass="teamsBox")
                        HtmlWriter._get_teams_content(
                            doc, tag, text, map_name,
                            HtmlWriter._custom_strftime(
                                '{S} of %B %Y', match_half1.start_time_stamp),
                            match_half1.start_time_stamp,
                            [team1_total_score, team2_total_score],
                            [team1_tick_score, team2_tick_score])

                    with tag("div"):
                        HtmlWriter._get_troop_report_separator(
                            doc, tag, text, "TEAM 1 WAR REPORT")

                        HtmlWriter._get_stats_content(
                            doc, tag, text, "Soldier name", team1_players,
                            match_half1.kill_stat_list +
                            match_half2.kill_stat_list,
                            match_half1.adr_stat_list +
                            match_half2.adr_stat_list,
                            match_half1.team_score_stat_list +
                            match_half2.team_score_stat_list,
                            match_half1.streak_stat_list +
                            match_half2.streak_stat_list)

                        HtmlWriter._get_troop_report_separator(
                            doc, tag, text, "TEAM 2 WAR REPORT")

                        HtmlWriter._get_stats_content(
                            doc, tag, text, "Soldier name", team2_players,
                            match_half1.kill_stat_list +
                            match_half2.kill_stat_list,
                            match_half1.adr_stat_list +
                            match_half2.adr_stat_list,
                            match_half1.team_score_stat_list +
                            match_half2.team_score_stat_list,
                            match_half1.streak_stat_list +
                            match_half2.streak_stat_list)

        output_dir = config.get("HTMLPageOutputSection", "output.dir")

        if not output_dir.endswith(os.sep):
            output_dir += os.sep

        f = io.open(output_dir + file_name + ".html", "w", encoding="utf-8")
        f.write(doc.getvalue())
        f.close()
コード例 #20
0
    def handle_proof(self, tag: QqTag) -> str:
        """
        Uses tags: proof, label, outline, of

        Examples:

            \proof
                Here is the proof

            \proof \of theorem \ref{thm:1}
                Now we pass to proof of theorem \ref{thm:1}

        :param tag:
        :return: HTML of proof
        """
        doc, html, text = Doc().tagtext()
        with html("div", klass="env env__proof"):
            if tag.find("label"):
                doc.attr(id=self.label2id(tag.label_.value))
            with html("span", klass="env-title env-title__proof"):
                if tag.exists("outline"):
                    proofline = 'Proof outline'
                else:
                    proofline = 'Proof'
                doc.asis(
                    join_nonempty(
                        self.localize(proofline),
                        self.format(tag.find("of"),
                                    blanks_to_pars=False)).rstrip() + ".")
            doc.asis(rstrip_p(" " + self.format(tag, blanks_to_pars=True)))
            doc.asis("<span class='end-of-proof'>&#8718;</span>")
        return doc.getvalue() + "\n<p>"
コード例 #21
0
ファイル: metadata.py プロジェクト: nunb/MaTiSSe
  def to_html(self, match, toc_depth=None, max_time=None, current=None):
    """Convert logo metadata to html stream.

    Parameters
    ----------
    match: re.match object
    max_time: str
      max time for presentation

    Returns
    -------
    str:
      html stream
    """
    if 'toc' in self.name:
      return self.toc_to_html(match=match, current=current, depth=int(toc_depth))
    if 'logo' in self.name:
      return self.logo_to_html(match)
    elif 'timer' in self.name:
      return self.timer_to_html(match=match, max_time=max_time)
    elif 'custom' in self.name:
      return self.custom_to_html(match)
    else:
      doc = Doc()
      with doc.tag('span', klass='metadata'):
        style = None
        if match.group('style'):
          style = str(match.group('style'))
        if style:
          doc.attr(style=style)
        if isinstance(self.value, list):
          doc.asis(', '.join(self.value))
        else:
          doc.asis(str(self.value))
    return doc.getvalue()
コード例 #22
0
ファイル: qqhtml.py プロジェクト: npmcdn-to-unpkg-bot/qqmbr
    def handle_h(self, tag: QqTag) -> str:
        """
        Uses tags: h1, h2, h3, h4, label, number

        Example:

            \h1 This is first header

            \h2 This is the second header \label{sec:second}

        :param tag:
        :return:
        """
        doc, html, text = Doc().tagtext()
        with html(tag.name):
            doc.attr(id=self.tag_id(tag))
            if tag.find("number"):
                with html("span", klass="section__number"):
                    with html("a",
                              href="#" + self.tag_id(tag),
                              klass="section__number"):
                        text(tag._number.value)
            text(self.format(tag, blanks_to_pars=False))
        ret = doc.getvalue()
        if tag.next() and isinstance(tag.next(), str):
            ret += "<p>"
        return doc.getvalue()
コード例 #23
0
ファイル: figure.py プロジェクト: noisyoscillator/MaTiSSe
 def to_html(self):
     """Convert self data to its html stream."""
     doc = Doc()
     with doc.tag('div', id='Figure-' + str(self.number)):
         if self.style:
             doc.attr(style=self.style)
         else:
             doc.attr(klass='figure')
         with doc.tag(self.ctn_type):
             if self.cap_position is not None and self.cap_position.upper(
             ) == 'TOP':
                 self.put_caption(doc=doc, klass='figure-caption')
             if self.ctn_options:
                 doc.stag('img',
                          src=self.ctn,
                          klass='figure-content',
                          style=self.ctn_options,
                          alt='Figure-' + self.ctn)
             else:
                 doc.stag('img',
                          src=self.ctn,
                          klass='figure-content',
                          style='width:100%;',
                          alt='Figure-' + self.ctn)
             if self.cap_position is None or self.cap_position.upper(
             ) == 'BOTTOM':
                 self.put_caption(doc=doc, klass='figure-caption')
     return doc.getvalue()
コード例 #24
0
ファイル: metadata.py プロジェクト: nunb/MaTiSSe
  def timer_to_html(self, match, max_time):
    """Convert custom metadata to html stream.

    Parameters
    ----------
    match: re.match object
    max_time: str

    Returns
    -------
    str:
      html stream
    """
    doc = Doc()
    with doc.tag('span', klass='timercontainer'):
      style = None
      if match.group('style'):
        style = str(match.group('style'))
      if style:
        doc.attr(style=style)
      with doc.tag('div', klass='countDown'):
        with doc.tag('div'):
          doc.attr(klass='timer')
        if style:
          if 'controls' in style:
            with doc.tag('div', klass='timercontrols'):
              with doc.tag('input', type='button'):
                doc.attr(klass='btn reset', onclick='resetCountdown(' + str(max_time) + ');', value=' &#10227; ', title='reset')
              with doc.tag('input', type='button'):
                doc.attr(klass='btn stop', onclick='stopCountdown();', value=' &#9724; ', title='pause')
              with doc.tag('input', type='button'):
                doc.attr(klass='btn start', onclick='startCountdown();', value=' &#9654; ', title='start')
    return doc.getvalue().replace('amp;', '')
コード例 #25
0
  def to_html(self, config):
    """Generate a html stream of the whole presentation.

    Parameters
    ----------
    config : MatisseConfig
      MaTiSSe configuration
    """
    doc, tag, text = Doc().tagtext()
    doc.asis('<!DOCTYPE html>')
    with tag('html'):
      # doc.attr(title=self.metadata['title'].value)
      self.__put_html_tag_head(doc=doc, tag=tag, text=text, config=config)
      with tag('body', onload="resetCountdown(" + str(self.metadata['max_time'].value) + ");"):
        doc.attr(klass='impress-not-supported')
        with tag('div', id='impress'):
          # numbering: [local_chap, local_sec, local_subsec, local_slide]
          current = [0, 0, 0, 0]
          for chapter in self.chapters:
            current[0] += 1
            current[1] = 0
            current[2] = 0
            current[3] = 0
            self.metadata['chaptertitle'].update_value(value=chapter.title)
            self.metadata['chapternumber'].update_value(value=chapter.number)
            for section in chapter.sections:
              current[1] += 1
              current[2] = 0
              current[3] = 0
              self.metadata['sectiontitle'].update_value(value=section.title)
              self.metadata['sectionnumber'].update_value(value=section.number)
              for subsection in section.subsections:
                current[2] += 1
                current[3] = 0
                self.metadata['subsectiontitle'].update_value(value=subsection.title)
                self.metadata['subsectionnumber'].update_value(value=subsection.number)
                for slide in subsection.slides:
                  current[3] += 1
                  self.metadata['slidetitle'].update_value(value=slide.title)
                  self.metadata['slidenumber'].update_value(value=slide.number)
                  with doc.tag('div'):
                    chapter.put_html_attributes(doc=doc)
                    section.put_html_attributes(doc=doc)
                    subsection.put_html_attributes(doc=doc)
                    slide.put_html_attributes(doc=doc)
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='header', current=current, overtheme=slide.overtheme)
                    # with doc.tag('div'):
                      # doc.attr(style='clear: both;')
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='sidebar', position='L', current=current, overtheme=slide.overtheme)
                    slide.to_html(doc=doc, parser=self.parser, metadata=self.metadata, theme=self.theme, current=current)
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='sidebar', position='R', current=current, overtheme=slide.overtheme)
                    # with doc.tag('div'):
                      # doc.attr(style='clear: both;')
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='footer', current=current, overtheme=slide.overtheme)
        self.__put_html_tags_scripts(doc=doc, tag=tag, config=config)
    # source = re.sub(r"<li>(?P<item>.*)</li>", r"<li><span>\g<item></span></li>", source)
    html = indent(doc.getvalue())
    return html
コード例 #26
0
ファイル: presentation.py プロジェクト: szaghi/MaTiSSe
  def to_html(self, config):
    """Generate a html stream of the whole presentation.

    Parameters
    ----------
    config : MatisseConfig
      MaTiSSe configuration
    """
    doc, tag, text = Doc().tagtext()
    doc.asis('<!DOCTYPE html>')
    with tag('html'):
      # doc.attr(title=self.metadata['title'].value)
      self.__put_html_tag_head(doc=doc, tag=tag, text=text, config=config)
      with tag('body', onload="resetCountdown(" + str(self.metadata['max_time'].value) + ");"):
        doc.attr(klass='impress-not-supported')
        with tag('div', id='impress'):
          # numbering: [local_chap, local_sec, local_subsec, local_slide]
          current = [0, 0, 0, 0]
          for chapter in self.chapters:
            current[0] += 1
            current[1] = 0
            current[2] = 0
            current[3] = 0
            self.metadata['chaptertitle'].update_value(value=chapter.title)
            self.metadata['chapternumber'].update_value(value=chapter.number)
            for section in chapter.sections:
              current[1] += 1
              current[2] = 0
              current[3] = 0
              self.metadata['sectiontitle'].update_value(value=section.title)
              self.metadata['sectionnumber'].update_value(value=section.number)
              for subsection in section.subsections:
                current[2] += 1
                current[3] = 0
                self.metadata['subsectiontitle'].update_value(value=subsection.title)
                self.metadata['subsectionnumber'].update_value(value=subsection.number)
                for slide in subsection.slides:
                  current[3] += 1
                  self.metadata['slidetitle'].update_value(value=slide.title)
                  self.metadata['slidenumber'].update_value(value=slide.number)
                  with doc.tag('div'):
                    chapter.put_html_attributes(doc=doc)
                    section.put_html_attributes(doc=doc)
                    subsection.put_html_attributes(doc=doc)
                    slide.put_html_attributes(doc=doc)
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='header', current=current, overtheme=slide.overtheme)
                    # with doc.tag('div'):
                      # doc.attr(style='clear: both;')
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='sidebar', position='L', current=current, overtheme=slide.overtheme)
                    slide.to_html(doc=doc, parser=self.parser, metadata=self.metadata, theme=self.theme, current=current)
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='sidebar', position='R', current=current, overtheme=slide.overtheme)
                    # with doc.tag('div'):
                      # doc.attr(style='clear: both;')
                    self.__put_html_slide_decorators(tag=tag, doc=doc, decorator='footer', current=current, overtheme=slide.overtheme)
        self.__put_html_tags_scripts(doc=doc, tag=tag, config=config)
    # source = re.sub(r"<li>(?P<item>.*)</li>", r"<li><span>\g<item></span></li>", source)
    html = indent(doc.getvalue())
    return html
コード例 #27
0
 def get_html(self, content, escape=True):
     doc, tag, text = Doc().tagtext()
     with tag(self._tag):
         text(content) if escape else doc.asis(content)
         if self._identity:
             doc.attr(id=self._identity)
         if self._classes:
             doc.attr(klass=self._classes)
     return doc.getvalue()
コード例 #28
0
    def handle_figure(self, tag: QqTag) -> str:
        """
        Currently, only python-generated figures and plotly figures are
        supported. Also one can use \rawhtml to embed arbitrary HTML code
        (e.g. use D3.js).

        Example:

        \figure \label fig:figure
            \pythonfigure
                plt.plot([1, 2, 3], [1, 4, 9])
            \caption
                Some figure

        Uses tags: figure, label, caption, number, showcode, collapsed

        :param tag: QqTag
        :return: HTML of figure
        """
        doc, html, text = Doc().tagtext()
        subtags = ['pythonfigure', 'plotly', 'rawhtml']
        langs = {
            'pythonfigure': 'python',
            'plotly': 'python',
            'rawhtml': 'html'
        }
        with html("div", klass="figure"):
            if tag.find("label"):
                doc.attr(id=self.label2id(tag.label_.value))
                label = tag.label_.value
            else:
                label = None
            for child in tag.children_tags():
                if child.name in subtags:
                    if tag.exists("showcode"):
                        doc.asis(
                            self.showcode(child,
                                          collapsed=tag.exists("collapsed"),
                                          lang=langs.get(child.name)))
                    doc.asis(self.handle(child))
                elif child.name == 'caption':
                    with html("div", klass="figure_caption"):
                        if label is not None:
                            with html("a",
                                      klass="figure_caption_anchor",
                                      href="#" + self.label2id(label)):
                                text(
                                    join_nonempty(self.localize("Fig."),
                                                  tag.get("number")))
                            text(": ")
                        else:
                            text(
                                join_nonempty(self.localize("Fig."),
                                              tag.get("number")) + ": ")
                        doc.asis(self.format(child, blanks_to_pars=True))
        return doc.getvalue()
コード例 #29
0
 def _get_parent_dir_link(parent_dir):
     """Get a link to the parent directory of the current page."""
     doc = Doc()
     with doc.tag('a'):
         if parent_dir == "":
             doc.attr(href=url_for('RawFile:index'))
         else:
             doc.attr(href=url_for('RawFile:get',
                                   name=parent_dir.replace('/', '|')))
         doc.text('Parent Dir')
     return doc.getvalue()
コード例 #30
0
ファイル: prettyt2h.py プロジェクト: ischurov/prettyt2h
def section_tag(level, title, label=None, number=None):
    doc, tag, text = Doc().tagtext()
    with tag("h" + str(level), klass=mk_safe_css_ident("section")):
        if label:
            doc.attr(id="label_" + mk_safe_css_ident(label))
        if number:
            with tag("span", klass="section__number"):
                text(number + ".")
            text(" ")
        text(title)
    return doc.getvalue() + "\n"
コード例 #31
0
def _bill_notifs(bill):
    if bill.state != 'paid' and bill.is_close_to_due():
        doc, tag, text = Doc().tagtext()
        with tag('span', klass=_NOTIFS_GLYPHICON + ' text-warning'):
            doc.attr('title', 'Bills is almost due')
        yield doc.getvalue()
    if bill.state != 'paid' and bill.is_overdue():
        doc, tag, text = Doc().tagtext()
        with tag('span', klass=_NOTIFS_GLYPHICON + ' text-danger'):
            doc.attr('title', 'Bill is overdue!')
        yield doc.getvalue()
コード例 #32
0
ファイル: box.py プロジェクト: gitter-badger/MaTiSSe
 def to_html(self):
   """Method for inserting box to the html doc."""
   doc = Doc()
   with doc.tag('div',klass='box'):
     if self.style:
       doc.attr(style=self.style)
     with doc.tag('div',klass='box content'):
       if self.ctn_options:
         doc.attr(style=self.ctn_options)
       doc.asis(self.ctn)
     self.put_caption(doc=doc)
   return doc.getvalue()
コード例 #33
0
 def to_html(self):
     """Method for inserting box to the html doc."""
     doc = Doc()
     with doc.tag('div', klass='box'):
         if self.style:
             doc.attr(style=self.style)
         with doc.tag('div', klass='box content'):
             if self.ctn_options:
                 doc.attr(style=self.ctn_options)
             doc.asis(self.ctn)
         self.put_caption(doc=doc)
     return doc.getvalue()
コード例 #34
0
ファイル: qqhtml.py プロジェクト: ischurov/qqmbr
    def handle_pythonfigure(self, tag: QqTag) -> str:
        """
        Uses tags: pythonfigure, style

        :param tag:
        :return:
        """

        path = self.make_python_fig(tag.text_content, exts=("svg"))
        doc, html, text = Doc().tagtext()
        with html("img", klass="figure img-responsive",
                  src=self.url_for_figure(path + "/" + self.default_figname + ".svg")):
            if tag.exists("style"):
                doc.attr(style=tag._style.value)
        return doc.getvalue()
コード例 #35
0
ファイル: box.py プロジェクト: nunb/MaTiSSe
 def to_html(self):
     """Method for inserting box to the html doc."""
     doc = Doc()
     with doc.tag("div", klass="box"):
         if self.style:
             doc.attr(style=self.style)
         if self.cap_position == "TOP":
             self.put_caption(doc=doc)
         with doc.tag("div", klass="box content"):
             if self.ctn_options:
                 doc.attr(style=self.ctn_options)
             doc.asis(self.ctn)
         if self.cap_position is None or self.cap_position == "BOTTOM":
             self.put_caption(doc=doc)
     return doc.getvalue()
コード例 #36
0
    def add_table_with_dict(data: dict):
        """
        add table

        Args:
            data (dict): list of key:value pairs to add to table row
        Returns: HTML String
        """
        doc = Doc()
        with doc.tag('table'):
            doc.attr(klass='standard_table')
            for key, items in data.items():
                with doc.tag('tr'):
                    doc.asis('<td>%s</td>' % key)
                    doc.asis('<td><b>%s</b></td>' % str(items))
        return doc.getvalue()
コード例 #37
0
 def to_html(self):
   """Convert self data to its html stream."""
   if self.number > 0:
     doc = Doc()
     with doc.tag('div', klass='columns'):
       for col, column in enumerate(self.columns):
         with doc.tag('div', klass='column'):
           doc.attr(('column-number', str(col + 1)))
           style = 'display:block;float:left;'
           if column[1]:
             style += column[1]
           else:
             style += 'width:' + str(int(100.0 / self.number)) + '%;'
           doc.attr(style=style)
           doc.asis(markdown2html(source=column[0]))
     return doc.getvalue()
   return ''
コード例 #38
0
    def handle_pythonfigure(self, tag: QqTag) -> str:
        """
        Uses tags: pythonfigure, style

        :param tag:
        :return:
        """

        path = self.make_python_fig(tag.text_content, exts=("svg", ))
        doc, html, text = Doc().tagtext()
        with html("img",
                  klass="figure img-responsive",
                  src=self.url_for_figure(path + "/" + self.default_figname +
                                          ".svg")):
            if tag.exists("style"):
                doc.attr(style=tag.style_.value)
        return doc.getvalue()
コード例 #39
0
    def add_overview_table_with_dict(data: dict):
        """
        add overview table with dict

        Args:
            data (dict): list of key:value pairs to add to table row
        Returns: HTML String
        """
        doc = Doc()
        with doc.tag('table'):
            doc.attr(klass='overview_table')
            for key, items in data.items():
                with doc.tag('tr'):
                    doc.asis('<td><b>%s</b></td>' % key)
                    for item in items:
                        doc.asis('<td>%s</td>' % item)
        return doc.getvalue()
コード例 #40
0
ファイル: columns.py プロジェクト: nunb/MaTiSSe
 def to_html(self):
   """Convert self data to its html stream."""
   if self.number > 0:
     doc = Doc()
     with doc.tag('div', klass='columns'):
       for col, column in enumerate(self.columns):
         with doc.tag('div', klass='column'):
           doc.attr(('column-number', str(col + 1)))
           style = 'display:block;float:left;'
           if column[1]:
             style += column[1]
           else:
             style += 'width:' + str(int(100.0 / self.number)) + '%;'
           doc.attr(style=style)
           doc.asis(markdown2html(source=column[0]))
     return doc.getvalue()
   return ''
コード例 #41
0
ファイル: figure.py プロジェクト: szaghi/MaTiSSe
 def to_html(self):
   """Convert self data to its html stream."""
   doc = Doc()
   with doc.tag('div', id='Figure-' + str(self.number)):
     if self.style:
       doc.attr(style=self.style)
     else:
       doc.attr(klass='figure')
     with doc.tag(self.ctn_type):
       if self.cap_position is not None and self.cap_position.upper() == 'TOP':
         self.put_caption(doc=doc, klass='figure-caption')
       if self.ctn_options:
         doc.stag('img', src=self.ctn, klass='figure-content', style=self.ctn_options, alt='Figure-' + self.ctn)
       else:
         doc.stag('img', src=self.ctn, klass='figure-content', style='width:100%;', alt='Figure-' + self.ctn)
       if self.cap_position is None or self.cap_position.upper() == 'BOTTOM':
         self.put_caption(doc=doc, klass='figure-caption')
   return doc.getvalue()
コード例 #42
0
ファイル: qqhtml.py プロジェクト: ischurov/qqmbr
    def handle_figure(self, tag: QqTag) -> str:
        """
        Currently, only python-generated figures and plotly figures are supported.

        Example:

        \figure \label fig:figure
            \pythonfigure
                plt.plot([1, 2, 3], [1, 4, 9])
            \caption
                Some figure

        Uses tags: figure, label, caption, number, showcode, collapsed

        :param tag: QqTag
        :return: HTML of figure
        """
        doc, html, text = Doc().tagtext()
        subtags = ['pythonfigure', 'plotly', 'rawhtml']
        langs = {'pythonfigure': 'python', 'plotly': 'python', 'rawhtml': 'html'}
        with html("div", klass="figure"):
            if tag.find("label"):
                doc.attr(id=self.label2id(tag._label.value))
                label = tag._label.value
            else:
                label = None
            for child in tag:
                if isinstance(child, QqTag):
                    if child.name in subtags:
                        if tag.exists("showcode"):
                            doc.asis(self.showcode(child, collapsed=tag.exists("collapsed"),
                                                   lang = langs.get(child.name)))
                        doc.asis(self.handle(child))
                    elif child.name == 'caption':
                        with html("div", klass="figure_caption"):
                            if label is not None:
                                with html("a", klass="figure_caption_anchor", href="#" + self.label2id(label)):
                                    text(join_nonempty(self.localize("Fig."), tag.get("number")))
                                text(": ")
                            else:
                                text(join_nonempty(self.localize("Fig."), tag.get("number"))+": ")
                            doc.asis(self.format(child, blanks_to_pars=True))
        return doc.getvalue()
コード例 #43
0
def stage_node(prop: dict):
    doc, tag, text, line = Doc().ttl()

    with tag('node', locked='false'):
        if prop['end']:
            doc.attr(doneState='true')
        else:
            doc.attr(doneState='false')

        line('text', prop['text'])

        line('uniqueID', prop['id'])

        with tag('dimension'):
            line('x', prop['x'])

            line('y', prop['y'])

    return doc.getvalue()
コード例 #44
0
ファイル: columns.py プロジェクト: nunb/MaTiSSe
 def to_html(self):
     """Method for inserting columns to the html doc."""
     if self.number > 0:
         doc = Doc()
         with doc.tag("div", klass="columns"):
             for col, column in enumerate(self.columns):
                 with doc.tag("div", klass="column"):
                     doc.attr(("column-number", str(col + 1)))
                     style = "display:block;float:left;"
                     if column[1]:
                         style += column[1]
                     else:
                         style += "width:" + str(int(100.0 / self.number)) + "%;"
                     doc.attr(style=style)
                     content = box_parse(column[0])
                     content = figure_parse(content)
                     content = table_parse(content)
                     content = note_parse(content)
                     doc.asis(seditor.md_convert(content))
         return doc.getvalue()
     return ""
コード例 #45
0
ファイル: columns.py プロジェクト: nunb/MaTiSSe
 def to_html(self):
   """Method for inserting columns to the html doc."""
   if self.number > 0:
     doc = Doc()
     with doc.tag('div',klass='columns'):
       for col,column in enumerate(self.columns):
         with doc.tag('div',klass='column'):
           doc.attr(('column-number',str(col+1)))
           style = 'display:block;float:left;'
           if column[1]:
             style += column[1]
           else:
             style += 'width:'+str(int(100.0/self.number))+'%;'
           doc.attr(style=style)
           content = box_parse(column[0])
           content = figure_parse(content)
           content = table_parse(content)
           content = note_parse(content)
           doc.asis(seditor.md_convert(content))
     return doc.getvalue()
   return ''
コード例 #46
0
ファイル: metadata.py プロジェクト: szaghi/MaTiSSe
  def custom_to_html(self, match):
    """Convert custom metadata to html stream.

    Parameters
    ----------
    match: re.match object

    Returns
    -------
    str:
      html stream
    """
    doc = Doc()
    with doc.tag('span', klass='metadata'):
      style = None
      if match.group('style'):
        style = str(match.group('style'))
      if style:
        doc.attr(style=style)
        doc.asis(re.search(r'value\:(?P<value>.*?)\;', style).group('value'))
    return doc.getvalue()
コード例 #47
0
ファイル: slide.py プロジェクト: nunb/MaTiSSe
  def metadata_to_html(self,metadata,style=None):
    """Method for converting slide level metadata to html.

    Parameters
    ----------
    metadata : str
      metadata key
    style : str, optional
      css style of metadata tag

    Returns
    -------
    str
      html string containing the metadata
    """
    doc = Doc()
    with doc.tag('span',klass='metadata'):
      if style:
        doc.attr(style=style)
      doc.asis(self.data[metadata])
    return doc.getvalue()
コード例 #48
0
ファイル: note.py プロジェクト: gitter-badger/MaTiSSe
 def to_html(self):
   """Method for inserting box to the html doc."""
   doc = Doc()
   with doc.tag('div',klass='note'):
     if self.style:
       doc.attr(style=self.style)
     elif Note.theme.data.data['style'][0]:
       doc.attr(style=Note.theme.data.data['style'][0])
     self.put_caption(doc=doc)
     with doc.tag('div',klass='note content'):
       if self.ctn_options:
         doc.attr(style=self.ctn_options)
       elif Note.theme.data.data['content'][0]:
         doc.attr(style=Note.theme.data.data['content'][0])
       doc.asis(seditor.md_convert(self.ctn))
   return doc.getvalue()
コード例 #49
0
ファイル: qqhtml.py プロジェクト: ischurov/qqmbr
    def handle_equation(self, tag: QqTag) -> str:
        """
        Uses tags: equation, number, label

        Example:

        \equation \label eq:first
            x^2 + y^2 = z^2

        :param tag:
        :return:
        """
        doc, html, text = Doc().tagtext()
        with html("div", klass="latex_equation"):
            text("\\[\n")
            text("\\begin{equation}\n")
            if tag.find('number'):
                text("\\tag{{{}}}\n".format(tag._number.value))
            if tag.find('label'):
                doc.attr(id=self.label2id(tag._label.value))
            text(self.format(tag, blanks_to_pars=False))
            text("\\end{equation}\n")
            text("\\]\n")
        return doc.getvalue()
コード例 #50
0
def generate_html(file_name='result.html'):
    results = monitor_runner.get_latest_status()
    print(results)

    doc, tag, text = Doc().tagtext()

    with tag('html'):
        with tag('body'):
            with tag('table', style='width: 100%'):
                for group in sorted(results):
                    with tag('tr'):
                        with tag('td', klass='group', colspan='3'):
                            with tag('h3', style='margin: 10px 0 0 0;'):
                                text(group)
                    for job_name in results[group]:
                        with tag('tr') as tr:
                            r = results[group][job_name]
                            if r['success']:
                                doc.attr(style='background: green;')
                            else:
                                doc.attr(style='background: red;')
                            with tag('td'):
                                text(job_name)
                            with tag('td'):
                                text(r['success'])
                            with tag('td'):
                                try:
                                    text('{:.1f}s'.format(r['response_time'].total_seconds()))
                                except:
                                    text('')
                            print(r)

    html = doc.getvalue()
    print(html)
    with open(file_name, "w", encoding='utf-8-sig') as f:
        f.write(html)
コード例 #51
0
ファイル: video.py プロジェクト: nunb/MaTiSSe
 def to_html(self):
   """Convert self data to its html stream."""
   doc = Doc()
   with doc.tag('div', id='video-' + str(self.number)):
     if self.style:
       doc.attr(style=self.style)
     else:
       doc.attr(klass='video')
     if self.cap_position is not None and self.cap_position.upper() == 'TOP':
       self.put_caption(doc=doc, klass='video-caption')
     with doc.tag('video', klass='video-content', controls=''):
       if self.ctn_options:
         doc.attr(style=self.ctn_options)
       else:
         doc.attr(style='width:100%;')
       doc.stag('source', src=self.ctn)
     if self.cap_position is None or self.cap_position.upper() == 'BOTTOM':
       self.put_caption(doc=doc, klass='video-caption')
   return doc.getvalue()
コード例 #52
0
ファイル: table.py プロジェクト: nunb/MaTiSSe
 def to_html(self):
   """Convert self data to its html stream."""
   doc = Doc()
   with doc.tag('div', id='table-' + str(self.number)):
     if self.style:
       doc.attr(style=self.style)
     else:
       doc.attr(klass='table')
     if self.cap_position is None or self.cap_position.upper() == 'TOP':
       self.put_caption(doc=doc, klass='table-caption')
     with doc.tag('div', klass='table-content'):
       if self.ctn_options:
         doc.attr(style=self.ctn_options)
       doc.asis(markdown2html(self.ctn, no_p=True))
     if self.cap_position is not None and self.cap_position.upper() == 'BOTTOM':
       self.put_caption(doc=doc, klass='table-caption')
   return doc.getvalue()
コード例 #53
0
ファイル: note.py プロジェクト: nunb/MaTiSSe
 def to_html(self):
     """Convert self data to its html stream."""
     doc = Doc()
     with doc.tag("div", id="note-" + str(self.number)):
         if self.style:
             doc.attr(style=self.style)
         else:
             doc.attr(klass="note")
         if self.cap_position is None or self.cap_position.upper() == "TOP":
             self.put_caption(doc=doc, klass="note-caption")
         with doc.tag("div", klass="note-content"):
             if self.ctn_options:
                 doc.attr(style=self.ctn_options)
             doc.asis(markdown2html(self.ctn, no_p=True))
         if self.cap_position is not None and self.cap_position.upper() == "BOTTOM":
             self.put_caption(doc=doc, klass="note-caption")
     return doc.getvalue()
コード例 #54
0
ファイル: figure.py プロジェクト: nunb/MaTiSSe
 def to_html(self):
   """Method for inserting box to the html doc."""
   doc = Doc()
   with doc.tag('div',klass='figure'):
     doc.attr(('id','Figure-'+str(self.number)))
     if self.style:
       doc.attr(style=self.style)
     elif Figure.theme.data.data['style'][0]:
       doc.attr(style=Figure.theme.data.data['style'][0])
     with doc.tag(self.ctn_type):
       if self.ctn_options:
         doc.stag('img',src=self.ctn,klass='image',style=self.ctn_options,alt='Figure-'+self.ctn)
       elif Figure.theme.data.data['content'][0]:
         doc.stag('img',src=self.ctn,klass='image',style=Figure.theme.data.data['content'][0],alt='Figure-'+self.ctn)
       else:
         doc.stag('img',src=self.ctn,klass='image',style='width:100%;',alt='Figure-'+self.ctn)
       self.put_caption(doc=doc)
   return doc.getvalue()
コード例 #55
0
ファイル: presentation.py プロジェクト: nunb/MaTiSSe
 def to_html(self):
   """Method for producing and html string document from presentation object."""
   doc, tag, text = Doc().tagtext()
   doc.asis('<!DOCTYPE html>')
   with tag('html'):
     doc.attr(title = self.metadata.data.data['title'][0])
     with tag('head'):
       doc.stag('meta',charset='utf-8')
       doc.stag('meta',author=' and '.join(self.metadata.data.data['authors'][0]))
       with tag('title'):
         text(self.metadata.data.data['title'][0])
       doc.stag('meta',subtitle=self.metadata.data.data['subtitle'][0])
       doc.stag('link',rel='stylesheet', href='css/normalize.css')
       if __config__.highlight:
         doc.stag('link',rel='stylesheet', href='js/highlight/styles/'+__config__.highlight_style)
       doc.stag('link',rel='stylesheet', href='css/theme.css')
     with tag('body',onload="resetCountdown("+self.metadata.data.data['max_time'][0]+");"):
       with tag('div',id='impress'):
         if self.titlepage.found:
           html = self.titlepage.to_html(position = self.pos, theme = self.theme.slide)
           html = self.metadata.parse(html)
           html = self.toc.parse(html)
           doc.asis(html)
         for section in self.sections:
           for subsection in section.subsections:
             for slide in subsection.slides:
               html = slide.to_html(position = self.pos, theme = self.theme.slide)
               html = self.metadata.parse(html)
               html = self.toc.parse(html,current=[int(slide.data['sectionnumber']),int(slide.data['subsectionnumber']),slide.number])
               doc.asis(html)
       with tag('script'):
         doc.attr(src='js/countDown.js')
       with tag('script'):
         doc.attr(src='js/impress.js')
       with tag('script'):
         doc.asis('impress().init();')
       if __config__.online_mathjax:
         with tag('script'):
           doc.attr(('type','text/javascript'))
           doc.attr(src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML')
       else:
         with tag('script'):
           doc.attr(('type','text/x-mathjax-config'))
           doc.text("""
             MathJax.Hub.Config({
               extensions: ["tex2jax.js"],
               jax: ["input/TeX", "output/HTML-CSS"],
               tex2jax: {
                 inlineMath: [ ['$','$'], ["\\(","\\)"] ],
                 displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
                 processEscapes: true
               },
               "HTML-CSS": { availableFonts: ["Neo-Euler"] }
             });
           """)
         with tag('script'):
           doc.attr(('type','text/javascript'))
           doc.attr(src='js/MathJax/MathJax.js')
       if __config__.highlight:
         with tag('script'):
           doc.attr(src='js/highlight/highlight.pack.js')
         with tag('script'):
           doc.text("""hljs.initHighlightingOnLoad();""")
   if __config__.indented:
     return indent(doc.getvalue())
   else:
     return doc.getvalue()
コード例 #56
0
ファイル: metadata.py プロジェクト: szaghi/MaTiSSe
  def toc_to_html(self, match, current=None, depth=1):
    """Convert TOC to a plain string.

    Parameters
    ----------
    match: re.match()
    current: [current_chapter, current_section, current_subsection, current_slide]
      eventual current chpater-section-subsection-slide number
    depth: int
      depth of TOC: 4 => up-to slides, 3 => up-to subsections, 2 => up-to sections, 1 => only chapters

    Returns
    -------
    str:
      plain string of TOC
    """
    def get_style(match):
      """Get TOC style if one.

      Parameters
      ----------
      match: re.match()

      Returns
      -------
      str:
        style
      """
      style = None
      if match.group('style'):
        style = str(match.group('style'))
      return style

    def get_actual_depth(style, depth):
      """Get the actual depth of TOC using the eventual provided depth or the one defined into the style.

      Parameters
      ----------
      style: str
      depth: int
        depth of TOC: 4 => up-to slides, 3 => up-to subsections, 2 => up-to sections, 1 => only chapters

      Returns
      -------
      int:
        actual depth
      """
      actual_depth = int(depth)
      if style is not None:
        if 'depth' in style.lower():
          match_depth = re.search(r'depth\:(?P<depth>[1-4])\;*', style)
          if match_depth.group('depth'):
            actual_depth = int(match_depth.group('depth'))
      return actual_depth

    style = get_style(match=match)
    actual_depth = get_actual_depth(style=style, depth=depth)
    doc = Doc()
    # numbering: [local_chap, local_sec, local_subsec, local_slide, global_slide]
    actual_current = [0, 0, 0, 0, 1]
    with doc.tag('div', klass='toc'):
      if style is not None:
        doc.attr(style=style)
      self.toc_put_chapters(doc=doc,
                            depth=actual_depth,
                            actual_current=actual_current,
                            current=current)
    return '\n' + doc.getvalue()