Пример #1
0
    def getvariationhtmls(self, position):
        global inputfiles

        def esceps(s):
            if len(s.strip()) == 0:
                return """<span style="font-weight: bold; color: red;">&epsilon;</span>"""
            else:
                return verbhtml.escapecode(s, allow_space_wrap=True)

        g1 = self.clone_groups[position]
        g2 = self.clone_groups[position + 1]

        result = []

        for ii in range(len(g1.instances)):
            g1file, g1start, g1end = g1.instances[ii]
            g2file, g2start, g2end = g2.instances[ii]

            if g1file != g2file:
                raise InternalException("Different files in variation groups")

            s = g1end + 1
            e = g2start - 1  # non-inclusive
            l = e - s  # non-inclusive above
            parts = xmllexer.get_texts_and_markups(s, l, inputfiles[g1file].lexintervals)

            hparts = [
                ExactCloneGroup.two_or_more_spaces_re.sub(" ", ExactCloneGroup.two_or_more_nlines_re.sub(" ", t))
                for t, k in parts if k == xmllexer.IntervalType.general and len(t) and not t.isspace()
                ]

            result.append(" " + esceps(" ".join(hparts)) + " ")

        return result
Пример #2
0
        def get_without_markup(b, e):
            l = e - b  # non-inclusive above

            parts = xmllexer.get_texts_and_markups(b, l, separated_intervals)

            hparts = [
                clones.ExactCloneGroup.two_or_more_spaces_re.sub(
                    " ",
                    clones.ExactCloneGroup.two_or_more_nlines_re.sub("\n", t))
                for t, k in parts if k in
                {xmllexer.IntervalType.general, xmllexer.IntervalType.comment}
                and len(t) and not t.isspace()
            ]

            return util.escapecode(" ".join(hparts), allow_space_wrap=True)
Пример #3
0
    def html(self, instance_no=0, allow_space_wrap=False):
        # ptext = self.plain_text(inst)
        # text = ptext

        ifilen, so, e = self.instances[instance_no]
        sl = e - so + 1
        parts = xmllexer.get_texts_and_markups(so, sl, inputfiles[ifilen].lexintervals)

        hparts = [
            "<code>" +
            verbhtml.escapecode(
                ExactCloneGroup.two_or_more_spaces_re.sub(" ", ExactCloneGroup.two_or_more_nlines_re.sub(" ", t)),
                allow_space_wrap) +
            "</code>"
            for t, k in parts if k == xmllexer.IntervalType.general and len(t) and not t.isspace()
        ]

        return "<wbr/>".join(hparts)  # can break line here