예제 #1
0
    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()
예제 #2
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()