How to use the atelier.rstgen.Table function in atelier

To help you get started, we’ve selected a few atelier examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lino-framework / lino / lino / utils / html2rst.py View on Github external
rst += ' '
    else:
        if e.tag not in IGNORED_TAGS:
            raise Exception("20150723 %s" % e.tag)

    if e.tail:
        rst += e.tail

    return rst


# def html2rst(e):
#     return _html2rst(e).strip()


class RstTable(rstgen.Table):

    """\
A table containing elementtree HTML:

.. complextable::
  :header:

  Code  Result 

  >>> from lino.utils.xmlgen.html import E
  >>> headers = [E.p("A ", E.b("formatted"), " header"), "A plain header"]
  >>> rows = [[1,2], [3,4]]
  >>> print (RstTable(headers).to_rst(rows))
  ======================== ================
   A **formatted** header   A plain header
  ------------------------ ----------------
github lino-framework / lino / lino / modlib / vocbook / base.py View on Github external
def write_body(self, fd):

        Section.write_body(self, fd)

        words = [w for w in self.words if w.parent is None]
        if words:
            t = rstgen.Table([col.label for col in self.columns],
                             show_headers=self.show_headers)
            t.write(fd, [self.tablerow(w) for w in words])

        for chunk in self.after:
            fd.write('\n\n' + chunk + '\n\n')
github lino-framework / lino / lino / modlib / vocbook / base.py View on Github external
def write_rst_files(self, root='.'):

        self.writing_format = 'rst'
        self.main.write_rst_files(root)

        if False:  # must convert to new structure
            fn = os.path.join('dict', 'et_fr.rst')
            logger.info("Generate %s", fn)
            fd = codecs.open(fn, 'w', 'utf-8')
            write_header(fd, 1, 'eesti-prantsuse')
            t = rstgen.Table(['Nr.', "ET", "FR", u"hääldamine", "Tasand"])
            self.words.sort(sort_by_et)
            words_et = [w for w in self.words if not w.hide_et]
            t.write(fd, [
                (i, w.et, html2rst(w.html_fr()),
                 w.pronounciation, w.lesson.rst_ref_to())
                for i, w in enumerate(words_et)])
            fd.close()