Esempio n. 1
0
 def html(self, inst=None, allow_space_wrap=False):
     import worddiff
     if inst is None: # all
         resultlist = worddiff.get_htmls(self.instancetexts)
         resulttexts = []
         for r in resultlist:
             resulttexts.append(
                 """<code id="%s" class="fuzzycode" style="display: %s;">%s</code>""" % (
                     "g" + str(self.id) + "-c" + str(len(resulttexts)),
                     "inline" if len(resulttexts) == 0 else "none",
                     r
                 )
             )
         return os.linesep.join(resulttexts)
     else:
         return "<code>" + verbhtml.escapecode(self.text(inst), allow_space_wrap) + "</code>"
Esempio n. 2
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
Esempio n. 3
0
    def summaryhtml(elements: 'list(VariativeElement)', fuzzy: 'bool'):
        start = string.Template(textwrap.dedent("""<!DOCTYPE html>
        <html lang="en">
        <head>
        <meta charset="utf-8">
        <title>Variative elements</title>
        <!-- link href="https://raw.githubusercontent.com/jcubic/jquery.splitter/master/css/jquery.splitter.css" rel="stylesheet"/ -->
        <style type="text/css">
        menu
        {
            display: none;
        }
        body
        {
            background-color: #dddddd;
            margin: 0px;
            overflow: hidden;
        }
        table
        {
            border-width: 1px 1px 0 0;
            border-spacing: 0;
            border-collapse: collapse;
            border-style: solid;
        }
        
        thead {
            height: 30px;
        }
        thead > tr {
            display: block;
            height: 30px;
        }
        
        tbody {
            background-color: #ffffff;
            display: block;
            overflow-y: scroll;
            /* height: calc(50vh - 30px); handle it with JS =( */ 
        }
        
        td, th
        {
            margin: 0;
            padding: 4px;
            border-width: 0 0 1px 1px;
            border-style: solid;
            font-family: sans-serif;
        }
        th
        {
            font-weight: normal;
            font-size: 10pt;
            vertical-align: bottom;
        }
        td
        {
            vertical-align: top;
        }
        
        th.fxd, td.fxd {
            width: 65px;
        }
        
        div #source {
            overflow-y: scroll;
            background-color: #ffffff;
            border: 1px solid black;
        }
        
        div #table {
            overflow: hidden;
        }
        div #blgd {
            display: none;
        }

        code.xmlmarkup {
            color: grey;
        }

        code.highlight, span.highlight {
            background-color: blue !important;
            color: white !important;
        }

        tr.multiple input[data-rel="create_dic"] {
            display: none;
        }

        tr.active  {
            background-color: #ffff88;
        }
        </style>
        <script src="jquery-2.0.3.min.js"></script>
        <!-- script src="https://raw.githubusercontent.com/jcubic/jquery.splitter/master/js/jquery.splitter-0.14.0.js"></script --> 
        <script src="interactivity.js"></script>
        </head>
        <body>

        <menu type="context" id="singlemenu">
          <menuitem label="Add to Dictionary" id="single2dict"></menuitem>
          <menuitem label="Create Information Element" id="single2elem"></menuitem>
        </menu>
        <menu type="context" id="multiplemenu">
          <menuitem label="Create Variative Element" id="multiple2elem"></menuitem>
        </menu>

        <div id="content">
        <div id="table">
        <table>
        <thead>
        <tr>
        <!-- <th>Participating groups</th> -->
        <th class="fxd">${colh0}</th>
        <th class="fxd">${colh1}</th>
        ${epts}
        <!-- <th>Variance of variants</th> -->
        <th class="tka">Candidate text</th>
        </tr>
        </thead>
        <tbody>""")).substitute(**(
            {
                'colh0': "№", 'colh1': "Clns/Grp", 'epts': "" if fuzzy else '<th class="fxd">Ext.pts</th>'
            }
        ))

        middle = textwrap.dedent("""</tbody></table>
        <div id="blgd">
        Blacklisted group descriptors:
        <textarea style="width:100%; height:100px;" id="black_descriptor_list"></textarea>
        2dict group descriptors:
        <textarea style="width:100%; height:100px;" id="todict_descriptor_list"></textarea>
        2elem group descriptors:
        <textarea style="width:100%; height:100px;" id="toelem_descriptor_list"></textarea>
        </div>
        </div>
        <span id="srclabel" style="height: 30px; vertical-align: bottom;">Source code:</span>
        <div id="source">
        <code>""")

        finish = textwrap.dedent("""
        </code>
        </div>
        </div>
        </body></html>""")

        global only_generate_for_ui
        source = "** generated for standalone UI **" if only_generate_for_ui else verbhtml.escapecode(inputfiles[0].text)

        return start + (os.linesep.join([e.html for e in elements])) + middle + source + finish
Esempio n. 4
0
 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)