Convert a DiffBase list into a pretty HTML report.
@return HTML representation.
430880
public String prettyHtml() {
        StringBuilder html = new StringBuilder();
        for (Change aDiff : getChangeList()) {
            String text = aDiff.text.replace("&", "&amp;")
                                    .replace("<", "&lt;")
                                    .replace(">", "&gt;")
                                    .replace("\n", "&para;<br>");
            switch (aDiff.operation) {
                case INSERT:
                    html.append("<ins style=\"background:#e6ffe6;\">").append(text)
                        .append("</ins>");
                    break;
                case DELETE:
                    html.append("<del style=\"background:#ffe6e6;\">").append(text)
                        .append("</del>");
                    break;
                case EQUAL:
                    html.append("<span>").append(text).append("</span>");
                    break;
            }
        }
        return html.toString();
    }
506211
public function diffedData()
    {
        if ($this->fromRecord) {
            $diffed = clone $this->fromRecord;
            $fields = array_keys($diffed->toMap() + $this->toRecord->toMap());
        } else {
            $diffed = clone $this->toRecord;
            $fields = array_keys($this->toRecord->toMap());
        }

        $hasOnes = array_merge($this->fromRecord->hasOne(), $this->toRecord->hasOne());

        // Loop through properties
        foreach ($fields as $field) {
            if (in_array($field, $this->ignoredFields)) {
                continue;
            }
            if (in_array($field, array_keys($hasOnes))) {
                continue;
            }

            // Check if a field from-value is comparable
            $toField = $this->toRecord->obj($field);
            if (!($toField instanceof DBField)) {
                continue;
            }
            $toValue = $toField->forTemplate();

            // Show only to value
            if (!$this->fromRecord) {
                $diffed->setField($field, DBField::create_field('HTMLFragment', "<ins>{$toValue}</ins>"));
                continue;
            }

            // Check if a field to-value is comparable
            $fromField = $this->fromRecord->obj($field);
            if (!($fromField instanceof DBField)) {
                continue;
            }
            $fromValue = $fromField->forTemplate();

            // Show changes between the two, if any exist
            if ($fromValue != $toValue) {
                $diffed->setField($field, DBField::create_field('HTMLFragment', Diff::compareHTML($fromValue, $toValue)));
            }
        }

        // Loop through has_one
        foreach ($hasOnes as $relName => $relSpec) {
            if (in_array($relName, $this->ignoredFields)) {
                continue;
            }

            // Create the actual column name
            $relField = "{$relName}ID";
            // Using relation name instead of database column name, because of FileField etc.
            $setField = is_a($relSpec, Image::class, true) ? $relName : $relField;
            $toTitle = '';
            /** @var DataObject $relObjTo */
            $relObjTo = null;
            if ($this->toRecord->hasMethod($relName)) {
                $relObjTo = $this->toRecord->$relName();
                $toTitle = $this->getObjectDisplay($relObjTo);
            }

            if (!$this->fromRecord) {
                $diffed->setField(
                    $setField,
                    DBField::create_field('HTMLFragment', "<ins>{$toTitle}</ins>")
                );
            } elseif ($this->fromRecord->$relField != $this->toRecord->$relField) {
                $fromTitle = '';
                $relObjFrom = null;
                if ($this->fromRecord->hasMethod($relName)) {
                    $relObjFrom = $this->fromRecord->$relName();
                    $fromTitle = $this->getObjectDisplay($relObjFrom);
                }

                // Set the field.
                $diffed->setField(
                    $setField,
                    DBField::create_field('HTMLFragment', Diff::compareHTML($fromTitle, $toTitle))
                );
            }
        }

        return $diffed;
    }
1087588
def diff_table(rawinfo, newinfo):
    '''
    
    '''
    return HtmlDiff.make_table(HtmlDiff(), rawinfo.split('\n'), newinfo.split('\n'),
                               context=True,
                               numlines=1)
288162
def to_html(self, codebase):
        
        body = ''
        for section in ('params', 'options', 'exceptions'):
            val = getattr(self, section)
            if val:
                body += '<h5>%s</h5>\n<dl class = "%s">%s</dl>' % (
                        printable(section), section, 
                        '\n'.join(param.to_html() for param in val))

        body += codebase.build_see_html(self.see, 'h5', self)
        return ('<a name = "%s" />\n<div class = "function">\n' + 
                '<h4>%s</h4>\n%s\n%s\n</div>\n') % (self.name, self.name, 
                    htmlize_paragraphs(codebase.translate_links(self.doc, self)), body)
286008
protected List<DCTree> htmlAttrs() {
        ListBuffer<DCTree> attrs = new ListBuffer<DCTree>();
        skipWhitespace();

        loop:
        while (isIdentifierStart(ch)) {
            int namePos = bp;
            Name name = readIdentifier();
            skipWhitespace();
            List<DCTree> value = null;
            ValueKind vkind = ValueKind.EMPTY;
            if (ch == '=') {
                ListBuffer<DCTree> v = new ListBuffer<DCTree>();
                nextChar();
                skipWhitespace();
                if (ch == '\'' || ch == '"') {
                    vkind = (ch == '\'') ? ValueKind.SINGLE : ValueKind.DOUBLE;
                    char quote = ch;
                    nextChar();
                    textStart = bp;
                    while (bp < buflen && ch != quote) {
                        if (newline && ch == '@') {
                            attrs.add(erroneous("dc.unterminated.string", namePos));
                            // No point trying to read more.
                            // In fact, all attrs get discarded by the caller
                            // and superseded by a malformed.html node because
                            // the html tag itself is not terminated correctly.
                            break loop;
                        }
                        attrValueChar(v);
                    }
                    addPendingText(v, bp - 1);
                    nextChar();
                } else {
                    vkind = ValueKind.UNQUOTED;
                    textStart = bp;
                    while (bp < buflen && !isUnquotedAttrValueTerminator(ch)) {
                        attrValueChar(v);
                    }
                    addPendingText(v, bp - 1);
                }
                skipWhitespace();
                value = v.toList();
            }
            DCAttribute attr = m.at(namePos).Attribute(name, vkind, value);
            attrs.add(attr);
        }

        return attrs.toList();
    }
1279893
def sheetToHTML(sheet):
    

    assert "SHEET" in str(type(sheet))
    #data,names=None,units=None,bookName=None,sheetName=None,xCol=None
    #sheet=OR.SHEET()
    data=sheet.data
    names=sheet.colDesc
    units=sheet.colUnits
    bookName=sheet.bookName
    sheetName=sheet.sheetName

    def htmlListToTR(l,trClass=None,tdClass=None,td1Class=None):
        """
        turns a list into a <tr><td>something</td></tr>
        call this when generating HTML tables dynamically.
        """
        html="<tr>"
        for item in l:
            html+="<td>%s</td>"%item
        html+="</tr>"
        if trClass:
            html=html.replace("<tr>",'<tr class="%s">'%trClass)
        if td1Class:
            html=html.replace("<td>",'<td class="%s">'%td1Class,1)
        if tdClass:
            html=html.replace("<td>",'<td class="%s">'%tdClass)
        return html

    htmlFname = os.path.expanduser("~")+"/WKS-%s.%s.html"%(bookName,sheetName)
    html="""<body>
    <style>
    body {
          background-color: #ababab;
          padding:20px;
          }
    table {
           font-size:12px;
           border-spacing: 0;
           border-collapse: collapse;
           }
    .name {background-color:#fafac8;text-align:center;}
    .units {background-color:#fafac8;text-align:center;}
    .data0 {background-color:#FFFFFF;font-family: monospace;text-align:center;}
    .data1 {background-color:#FAFAFA;font-family: monospace;text-align:center;}
    .labelRow {background-color:#e0dfe4; text-align:right;border:1px solid #000000;}
    .labelCol {background-color:#e0dfe4; text-align:center;border:1px solid #000000;  padding-left: 20px; padding-right: 20px;}
    td {
        border:1px solid #c0c0c0; padding:5px;
        font-family: Arial, Helvetica, sans-serif;
        }
    </style>
    <html>"""
    html+="<h1>FauxRigin</h1>"
    if bookName or sheetName:
        html+='<code><b>%s / %s</b></code><br><br>'%(bookName,sheetName)
    html+="<table>"
    colNames=['']
    for i in range(len(units)):
        shortName=chr(i%26+ord('A'))
        if i>=26:
            shortName=chr(int(i/26-1)+ord('A'))+shortName
        label="%s(%s)"%(shortName,"X" if sheet.colTypes[i]==3 else "Y")
        colNames.append(label)
    html+=htmlListToTR(colNames,'labelCol','labelCol')
    html+=htmlListToTR(['Long Name']+list(names),'name',td1Class='labelRow')
    html+=htmlListToTR(['Units']+list(units),'units',td1Class='labelRow')
    cutOff=False
    for y in range(len(data)):
        html+=htmlListToTR([y+1]+list(data[y]),trClass='data%d'%(y%2),td1Class='labelRow')
        if y>=200:
            cutOff=True
            break
    html+="</table>"
    html=html.replace(">nan<",">--<")
    html=html.replace(">None<","><")
    if cutOff:
        html+="<h3>... showing only %d of %d rows ...</h3>"%(y,len(data))
    html+="</body></html>"
    with open(htmlFname,'w') as f:
        f.write(html)
    import webbrowser
    webbrowser.open(htmlFname)
    return
112730
def make_diff(current, revision):
    """"""
    the_diff = []
    dmp = diff_match_patch()

    for field in (set(current.field_dict.keys()) | set(revision.field_dict.keys())):
        # These exclusions really should be configurable
        if field == 'id' or field.endswith('_rendered'):
            continue
        # KeyError's may happen if the database structure changes
        # between the creation of revisions. This isn't ideal,
        # but should not be a fatal error.
        # Log this?
        missing_field = False
        try:
            cur_val = current.field_dict[field] or ""
        except KeyError:
            cur_val = "No such field in latest version\n"
            missing_field = True
        try:
            old_val = revision.field_dict[field] or ""
        except KeyError:
            old_val = "No such field in old version\n"
            missing_field = True
        if missing_field:
            # Ensure that the complete texts are marked as changed
            # so new entries containing any of the marker words
            # don't show up as differences
            diffs = [(dmp.DIFF_DELETE, old_val), (dmp.DIFF_INSERT, cur_val)]
            patch =  dmp.diff_prettyHtml(diffs)
        elif isinstance(cur_val, Markup):
            # we roll our own diff here, so we can compare of the raw
            # markdown, rather than the rendered result.
            if cur_val.raw == old_val.raw:
                continue
            diffs = dmp.diff_main(old_val.raw, cur_val.raw)
            patch =  dmp.diff_prettyHtml(diffs)
        elif cur_val == old_val:
            continue
        else:
            # Compare the actual field values
            diffs = dmp.diff_main(force_text(old_val), force_text(cur_val))
            patch = dmp.diff_prettyHtml(diffs)
        the_diff.append((field, patch))

    the_diff.sort()
    return the_diff
901749
def html_diff(self, old, new):
        
        def html_transition(old_type, new_type):
            tags = []
            for tag in [("/", old_type), ("", new_type)]:
                if tag[1] not in ["+", "-"]:
                    continue
                tags.append("<{}{}>".format(tag[0], "ins" if tag[1] == "+" else "del"))
            return "".join(tags)

        return self._char_diff(old, new, html_transition, fmt=cgi.escape)
1223222
public String getDiffHtml() throws Exception {

        CmsDiffViewMode mode = "all".equals(m_diffMode) ? CmsDiffViewMode.ALL : CmsDiffViewMode.DIFF_ONLY;
        String text1 = m_text1;
        String text2 = m_text2;
        if ("text".equals(m_textMode)) {
            text1 = CmsHtml2TextConverter.html2text(text1, "UTF-8");
            text2 = CmsHtml2TextConverter.html2text(text2, "UTF-8");
        }
        CmsHtmlDifferenceConfiguration conf = new CmsHtmlDifferenceConfiguration(
            mode == CmsDiffViewMode.ALL ? -1 : 2,
            A_CmsUI.get().getLocale());
        String diff = Diff.diffAsHtml(text1, text2, conf);
        String html = null;
        if (CmsStringUtil.isNotEmpty(diff)) {
            html = diff;
        } else {
            html = wrapLinesWithUnchangedStyle(
                CmsStringUtil.substitute(CmsStringUtil.escapeHtml(m_text1), "<br/>", ""));
        }
        return html;

    }
671573
protected function _real_toHtml() {
        if ( ! $this->_directCall) {
            $this->_directCall = 'getGroupedHtml';
        }
        switch ($this->_directCall) {
            case 'getHtml':
                $html = parent::getHtml($this->_singleRenderType);
                $this->_singleRenderType = self::NO_SINGLE_RENDER_TYPE;
                break;
            case 'getGroupedHtml':
            default:
                $html = parent::getGroupedHtml();
                break;
        }
        return $html;
    }
910264
def generate_html_report(base_path, asset_id):
    '''
    
    '''
    jenv = Environment(loader=PackageLoader('swchange', 'templates'))
    s = Session()
    #hosts = s.query(Host).filter_by(asset_id=asset_id).all()
    asset = s.query(AssetList).filter_by(id=asset_id).first()
    if not asset:
        print 'Invalid Asset ID (%s)!' % asset_id
        return
    filename = os.path.join(base_path, '%s-INV-CHANGE-%s.html' % (
        asset.name,
        datetime.now().strftime('%Y-%m-%d.%H.%M.%S'))
    )
    print 'Generating Report : %s' % filename
    with open(filename, 'wb') as report:
        report.write(jenv.get_template('layout.html').render(
            asset=asset,
            current_date=datetime.now()
        ))
464692
function htmlReporter(reports, options = {}) {
  var {hide} = options;
  hide = hide || {};

  function htmlReporterOne({children, desc, status, counts, time, code}) {
    var text = T(desc);
    var attrs = {class: {[status]: true}};
    if (children) {
      return E('details') .
        has([
          E('summary') . has([text, !hide.counts && T(` (${makeCounts(counts)})`)]) . is(attrs),
          E('div') . has(htmlReporter(children, options))
        ]) .
        is(hide.children ? {} : {open: true});
    } else {
      return E('div') . has(text) . is(attrs);
    }
  }

  return M(reports, htmlReporterOne);
}
600736
public static String getDiff(String old, String newData, String identify, String htmlClick) {

        StringComparator stringComparator = new StringComparator(old, newData);
        String contentString = StringEscapeUtils.escapeHtml4(identify) + "<br/><br/>" + htmlClick + "<br/> ";

        try {

            if (stringComparator.getChangesFromOriginal().size() == 0 &&
                    stringComparator.getDeletesFromOriginal().size() == 0 &&
                    stringComparator.getInsertsFromOriginal().size() == 0) {

                return "<span style='color:#FF0000'>OK, NO MODIFICATOIN!</span>";

            } else {

                String oldValue = "<br/><br/><br/><span style='color:#FF0000'>Old value:</span><br/>" +
                        StringEscapeUtils.escapeHtml4(old).replaceAll("\n", "<br/>");

                String newValue = "<br/><br/><br/><span style='color:#FF0000'>New value:</span><br/>" +
                        StringEscapeUtils.escapeHtml4(newData).replaceAll("\n", "<br/>");

                String diff = "";
                if (stringComparator.getChangesFromOriginal().size() != 0) {
                    diff = "<span style='color:#FF0000'>Change info: </span><br/>";
                    for (Chunk chunk : stringComparator.getChangesFromOriginal()) {
                        diff += StringEscapeUtils.escapeHtml4(chunk.toString()) + "<br/>";
                    }
                }

                if (stringComparator.getInsertsFromOriginal().size() != 0) {
                    diff += "<br/><span style='color:#FF0000'>Insert info: </span><br/>";
                    for (Chunk chunk : stringComparator.getInsertsFromOriginal()) {
                        diff += StringEscapeUtils.escapeHtml4(chunk.toString()) + "<br/>";
                    }
                }

                if (stringComparator.getDeletesFromOriginal().size() != 0) {
                    diff += "<br/><span style='color:#FF0000'>Delete info: </span><br/>";
                    for (Chunk chunk : stringComparator.getDeletesFromOriginal()) {
                        diff += StringEscapeUtils.escapeHtml4(chunk.toString()) + "<br/>";
                    }
                }

                return contentString + diff + oldValue + newValue;
            }

        } catch (IOException e) {
            LOG.error("compare error", e);

            return "comparator error" + e.toString();
        }
    }
636977
public function buildHtml()
	{
		$list	= array();
		$divs	= array();
		foreach( $this->steps as $nr => $step )
		{
			$id		= $this->id."_link".$nr;
			$list[]	= UI_HTML_Elements::ListItem( $step['label'], 0, array( 'id' => $id ) );
			$id		= $this->id."_".$nr;
			$divs[] = UI_HTML_Tag::create( 'div', $step['content'], array( 'id' => $id ) );
		}
		$list	= UI_HTML_Elements::unorderedList( $list );
		$divs	= implode( "\n", $divs );
		$div	= UI_HTML_Tag::create( 'div', "\n".$list.$divs."\n", array( 'id' => $this->id ) );
		return $div;
	}
1203152
function diffTable(results) {
  var curRefs = $('.references-list li').text().toString().split('\n').map(function(r) { return r.trim(); });
  $('#sbResults').html('<table><thead><tr><th>Title</th><th>Created</th><th>Source</th></tr></thead><tbody></tbody></table>');
  console.log('diffResults', results);
  if (results && results.hits.total > 0) {
    var t, created;
    t += '<tr><th colspan="4">Included</th></tr>';
    _.pluck(results.hits.hits, '_source').forEach(function(r) {
      created = false;
      // included annos

      r.annotations.forEach(function(a) {
        if (a.key === 'DateCreated' && new Date(a.typed.Date) < new Date(2013, 4)) {
          if (curRefs.indexOf(r.title) > -1) {
            created = a.typed.Date;
          }
        }
      });
      if (created) {
        r.created = created;
        t += _.template('<tr><td><a href="<%= uri %>"><%= title %></a></td><td><%= created %></td><td><div class="ui tiny buttons"><div class="ui basic tiny button">PubMed</div></td></tr>', r);
      }
      $('#sbResults table').append(t);
    });

    t += '<tr><th colspan="4">Not included</th></tr>';
    _.pluck(results.hits.hits, '_source').forEach(function(r) {
      created = false;
      // included annos

      r.annotations.forEach(function(a) {
        if (a.key === 'DateCreated' && new Date(a.typed.Date) < new Date(2013, 4)) {
          if (curRefs.indexOf(r.title) < 0) {
            created = a.typed.Date;
          }
        }
      });
      if (created) {
        r.created = created;
        t += _.template('<tr><td><a href="<%= uri %>"><%= title %></a></td><td><%= created %></td><td><div class="ui tiny buttons"><div class="ui basic tiny button">PubMed</div></td></tr>', r);
      }
      $('#sbResults tbody').append(t);
    });

    t += '<tr><th colspan="4">New</th></tr>';
    _.pluck(results.hits.hits, '_source').forEach(function(r) {
      created = false;
      // included annos

      r.annotations.forEach(function(a) {
        if (a.key === 'DateCreated' && new Date(a.typed.Date) > new Date(2013, 3)) {
          created = a.typed.Date;
        }
      });
      if (created) {
        r.created = created;
        t += _.template('<tr><td><a href="<%= uri %>"><%= title %></a></td><td><%= created %></td><td><div class="ui tiny buttons"><div class="ui basic tiny button">PubMed</div></td></tr>', r);
      }
      $('#sbResults table').html(t);
    });
  }
}
1269820
def _repr_html_(self):
    
    parts = []
    if self._class:
      parts.append('<div id="hh_%s" class="%s">%s</div>' % (self._id, self._class, self._markup))
    else:
      parts.append('<div id="hh_%s">%s</div>' % (self._id, self._markup))

    if len(self._script) != 0:
      parts.append('<script>')
      parts.append('require([')
      parts.append(','.join(['"%s"' % d[0] for d in self._dependencies]))
      parts.append('], function(')
      parts.append(','.join([d[1] for d in self._dependencies]))
      parts.append(') {')
      parts.append(self._script)
      parts.append('});')
      parts.append('</script>')

    return ''.join(parts)
640156
protected DCTree html() {
        int p = bp;
        nextChar();
        if (isIdentifierStart(ch)) {
            Name name = readIdentifier();
            List<DCTree> attrs = htmlAttrs();
            if (attrs != null) {
                boolean selfClosing = false;
                if (ch == '/') {
                    nextChar();
                    selfClosing = true;
                }
                if (ch == '>') {
                    nextChar();
                    DCTree dctree = m.at(p).newStartElementTree(name, attrs, selfClosing).setEndPos(bp);
                    return dctree;
                }
            }
        } else if (ch == '/') {
            nextChar();
            if (isIdentifierStart(ch)) {
                Name name = readIdentifier();
                skipWhitespace();
                if (ch == '>') {
                    nextChar();
                    return m.at(p).newEndElementTree(name);
                }
            }
        } else if (ch == '!') {
            nextChar();
            if (ch == '-') {
                nextChar();
                if (ch == '-') {
                    nextChar();
                    while (bp < buflen) {
                        int dash = 0;
                        while (ch == '-') {
                            dash++;
                            nextChar();
                        }
                        // Strictly speaking, a comment should not contain "--"
                        // so dash > 2 is an error, dash == 2 implies ch == '>'
                        // See http://www.w3.org/TR/html-markup/syntax.html#syntax-comments
                        // for more details.
                        if (dash >= 2 && ch == '>') {
                            nextChar();
                            return m.at(p).newCommentTree(newString(p, bp));
                        }

                        nextChar();
                    }
                }
            }
        }

        bp = p + 1;
        ch = buf[bp];
        return erroneous("dc.malformed.html", p);
    }