Creates a preformatted HTML version of the description.
499623
def preformat_plain_description(testcase):
    """"""
    description = testcase.get("description")

    if not description:
        return

    # naive approach to removing indent from pytest docstrings
    nodeid = testcase.get("nodeid") or ""
    indent = None
    if "::Test" in nodeid:
        indent = 8 * " "
    elif "::test_" in nodeid:
        indent = 4 * " "

    if indent:
        orig_lines = description.split("\n")
        new_lines = []
        for line in orig_lines:
            if line.startswith(indent):
                line = line.replace(indent, "", 1)
            new_lines.append(line)
        description = "\n".join(new_lines)

    testcase["description"] = "<pre>\n{}\n</pre>".format(description)
179725
public String toHTML() {
        StringBuilder builder = new StringBuilder();

        int numClasses = classes.size();
        // Header Row
        builder.append("<table>\n");
        builder.append("<tr><th class=\"empty-space\" colspan=\"2\" rowspan=\"2\">");
        builder.append(String.format("<th class=\"predicted-class-header\" colspan=\"%d\">Predicted Class</th></tr>%n",
                        numClasses + 1));

        // Predicted Classes Header Row
        builder.append("<tr>");
        // builder.append("<th></th><th></th>");
        for (T predicted : classes) {
            builder.append("<th class=\"predicted-class-header\">");
            builder.append(predicted);
            builder.append("</th>");
        }
        builder.append("<th class=\"predicted-class-header\">Total</th>");
        builder.append("</tr>\n");

        // Data Rows
        String firstColumnLabel = String.format(
                        "<tr><th class=\"actual-class-header\" rowspan=\"%d\">Actual Class</th>", numClasses + 1);
        for (T actual : classes) {
            builder.append(firstColumnLabel);
            firstColumnLabel = "<tr>";
            builder.append(String.format("<th class=\"actual-class-header\" >%s</th>", actual));

            for (T predicted : classes) {
                builder.append("<td class=\"count-element\">");
                builder.append(getCount(actual, predicted));
                builder.append("</td>");
            }

            // Actual Class Totals Column
            builder.append("<td class=\"count-element\">");
            builder.append(getActualTotal(actual));
            builder.append("</td>");
            builder.append("</tr>\n");
        }

        // Predicted Class Totals Row
        builder.append("<tr><th class=\"actual-class-header\">Total</th>");
        for (T predicted : classes) {
            builder.append("<td class=\"count-element\">");
            builder.append(getPredictedTotal(predicted));
            builder.append("</td>");
        }
        builder.append("<td class=\"empty-space\"></td>\n");
        builder.append("</tr>\n");
        builder.append("</table>\n");

        return builder.toString();
    }
987511
def generate_headline_from_description(sender, instance, *args, **kwargs):
    '''
    
    '''
    lines = instance.description.split('\n')
    headline = truncatewords(lines[0], 20)
    if headline[:-3] == '...':
        headline = truncatechars(headline.replace(' ...', ''), 250)  # Just in case the words exceed char limit.
    else:
        headline = truncatechars(headline, 250)
    instance.headline = headline
743739
function (description, since) {
			var result = description || "";

			if (since) {
				result += '<br><br><i>Since: ' + since + '.</i>';
			}

			result = this._preProcessLinksInTextBlock(result);
			return result;
		}
1049350
public String format(Description description) {
		for (BlockElement blockElement : description.getBlocks()) {
			blockElement.format(this);
		}
		return finalizeFormatting();
	}
910323
public CreateWebhookParams description(String description) {
        String value = (description==null) ? "" : description;
        parameters.add(new NameValuePair("description", value));
        return this;
    }
1067643
def to_html
      html = '<table><tr>'
      @source.each{|color| html.concat("<th>" + color + "</th>")}
      html.concat("</tr><tr>")
      @source.each{|color| html.concat("<td style=\"background-color:" + color + ";\">&nbsp;</td>")}
      html += '</tr></table>'
      return html
    end
193051
def to_html(self):
        
        if self.items is None:
            return
        else:
            html = '<ol%s>\n' % self.html_attributes()
            for item in self.items:
                html += '<li>%s</li>\n' % item.to_html()
            html += '</ol>'
            return html
166808
def prettify(elem):
    """"""
    rough_string = E.tostring(elem, 'utf-8')
    reparsed = minidom.parseString(rough_string)
    return reparsed.toprettyxml(indent='  ').strip()
1158580
function buildHTML(segments) {
		var html = '';
		for (var i=0; i<segments.length; i++) {
			html += buildHTMLForSegment(segments[i]);
		}
		return html;
	}
287604
def generate_html(attrs, api_key):
    '''  '''
    # getting flickr api data
    flickr_data = get_info(attrs['photo_id'], api_key)

    # if size is not defined it will use large as image size
    if 'size' not in attrs.keys():
        attrs['size'] = 'large'

    # if no alt is defined it will use the flickr image title
    if 'alt' not in attrs.keys():
        attrs['alt'] = flickr_data['photo']['title']['_content']

    # return final html code
    return '<a href="{}"><img src="{}" alt="{}"></a>'.format(
        flickr_data['photo']['urls']['url'][0]['_content'],
        source_url(flickr_data['photo']['farm'],
                   flickr_data['photo']['server'],
                   attrs['photo_id'],
                   flickr_data['photo']['secret'],
                   attrs['size']),
        attrs['alt'])
144338
def html(self, text=TEXT):
        
        self.logger.debug("Generating the HTML report{}..."
                          .format(["", " (text only)"][text]))
        html = []
        for piece in self._pieces:
            if isinstance(piece, string_types):
                html.append(markdown2.markdown(piece, extras=["tables"]))
            elif isinstance(piece, Element):
                html.append(piece.html())
        return "\n\n".join(html)
815858
def to_html(doc, output="/tmp", style="dep"):
    
    # generate filename from first six non-punct tokens
    file_name = "-".join([w.text for w in doc[:6] if not w.is_punct]) + ".html"
    html = displacy.render(doc, style=style, page=True)  # render markup
    if output is not None:
        output_path = Path(output)
        if not output_path.exists():
            output_path.mkdir()
        output_file = Path(output) / file_name
        output_file.open("w", encoding="utf-8").write(html)  # save to file
        print("Saved HTML to {}".format(output_file))
    else:
        print(html)
1053747
function createCttEntity(id, html, cb) {

    let state = null
    let messages = []

    try {
        html = htmlBeautify(html)
        let $ = parser.load(html)

        let table = $('table.full-width tr').get(1).children.filter(e => e.type == 'tag')

        let dayAndHours = table[2].children[0].data.trim() + ' ' + table[3].children[0].data.trim()
        state = {
            date: moment.tz(dayAndHours, "YYYY/MM/DD HH:mm", zone).format()
        }

        if(table[4].children.length == 0) {
            state['status'] = 'Sem estado'
        } else {
            if(table[4].children[0].data) {
                state['status'] = table[4].children[0].data.trim()
            } else {
                state['status'] = table[4].children[0].children[0].data.trim()
            }
        }

        let details = $('#details_0').find('tr')

        let day = ""
        let dayUnformated = ""
        let message = {}
        for(let i = 0; i < details.length; i++) {
            let tr = details.get(i)
            if(tr.children.length >= 8){
                let idxsum = 0

                if(tr.children.length >= 9) {
                    day = tr.children[0].children[0].data.trim()
                    dayUnformated = day.split(',')[1].trim()
                    day = moment.tz(dayUnformated, "DD MMMM YYYY", 'pt', zone).format()
                    message = {
                        day: day,
                        status: []
                    }
                    messages.push(message)
                    idxsum = 1
                }

                let hours = tr.children[0+idxsum].children[0].data.trim()
                let time = moment.tz(dayUnformated + ' ' + hours, "DD MMMM YYYY HH:mm", 'pt', zone).format()
                let add = {
                    time: time,
                    status: tr.children[2+idxsum].children[0].data.trim(),
                    local: tr.children[6+idxsum].children[0].data.trim()
                }
                message.status.push(add)
            }
        }

    } catch (error) {
        return cb(error)
    }

    cb(null, new CttInfo(id, state, messages))

}
176338
def html(self):
        
        return """
        <div class="property"><i>{name}</i><br/>
        <pre>{value}</pre></div>
        """.format(name=tag.text(self.name), value=tag.text(self.value))
1165619
def makeHTML(self,mustachepath,htmlpath):
        ''' '''
        subs = dict()
        if self.title:
            subs["title"]=self.title
            subs["has_title"]=True
        else:
            subs["has_title"]=False
        subs["font_size"] = self.font_size
        subs["font_family"] = self.font_family
        subs["colorscheme"] = self.colorscheme
        subs["title_color"] = self.title_color
        subs["bgcolor"] = self.bgcolor
        with open(mustachepath,'r') as infile:
            mustache_text = pystache.render(infile.read(), subs)
            with open(htmlpath,'w+') as outfile:
                outfile.write(mustache_text)
570895
def _htmlify_text(self, s):
    """"""
    colored = self._handle_ansi_color_codes(html.escape(s))
    return linkify(self._buildroot, colored, self._linkify_memo).replace('\n', '</br>')