// HTML returns an HTML representations of the contents of one row of a table.
320763
func (r *Row) HTML(tag string, style *renderStyle) string {
	attrs := make([]string, len(r.cells))
	elems := make([]string, len(r.cells))
	for i := range r.cells {
		if r.cells[i].alignment != nil {
			switch *r.cells[i].alignment {
			case AlignLeft:
				attrs[i] = " align='left'"
			case AlignCenter:
				attrs[i] = " align='center'"
			case AlignRight:
				attrs[i] = " align='right'"
			}
		}
		elems[i] = html.EscapeString(strings.TrimSpace(r.cells[i].Render(style)))
	}
	// WAG as to max capacity, plus a bit
	buf := bytes.NewBuffer(make([]byte, 0, 8192))
	buf.WriteString("<tr>")
	for i := range elems {
		fmt.Fprintf(buf, "<%s%s>%s</%s>", tag, attrs[i], elems[i], tag)
	}
	buf.WriteString("</tr>\n")
	return buf.String()
}
1285781
func (self htmlIdImpl) TextAttribute() DomAttribute {
	return self.getOrCreateAttribute("text", func() DomAttribute {
		return NewTextAttr(self.t)
	})
}
1345571
func (s *Selection) PrependHtml(html string) *Selection {
	return s.PrependNodes(parseHtml(html)...)
}
807755
func htmlCopy(item interface{}) interface{} {
	kind := reflect.TypeOf(item).Kind()
	original := reflect.ValueOf(item)

	if kind == reflect.Slice {
		clone := []interface{}{}
		for i := 0; i < original.Len(); i += 1 {
			clone = append(clone, htmlCopy(original.Index(i).Interface()))
		}
		return clone
	} else if kind == reflect.Map {
		clone := map[string]interface{}{}
		for key, val := range item.(map[string]interface{}) {
			clone[key] = htmlCopy(val)
		}
		return clone
	} else if kind == reflect.String {
		return template.HTML(fmt.Sprint(item))
	} else {
		return item
	}
}
1364318
func (p *WebPage) Content() (string, error) {
	var resp struct {
		Value string `json:"value"`
	}
	if err := p.ref.process.doJSON("POST", "/webpage/Content", map[string]interface{}{"ref": p.ref.id}, &resp); err != nil {
		return "", err
	}
	return resp.Value, nil
}
954414
func (c *Cell) Render(style *renderStyle) (buffer string) {
	// if no alignment is set, import the table's default
	if c.alignment == nil {
		c.alignment = &style.Alignment
	}

	// left padding
	buffer += strings.Repeat(" ", style.PaddingLeft)

	// append the main value and handle alignment
	buffer += c.alignCell(style)

	// right padding
	buffer += strings.Repeat(" ", style.PaddingRight)

	// this handles escaping for, eg, Markdown, where we don't care about the
	// alignment quite as much
	if style.replaceContent != nil {
		buffer = style.replaceContent(buffer)
	}

	return buffer
}
469795
func (ctx *MyContext) HTML(htmlContents string) (int, error) {
	ctx.Application().Logger().Infof("Executing .HTML function from MyContext")

	ctx.ContentType("text/html")
	return ctx.WriteString(htmlContents)
}
203218
func (r *Render) HTML(w io.Writer, status int, name string, binding interface{}) error {
	return r.Render.HTML(w, status, name, binding)
}
1285612
func OutputHTML(n *html.Node, self bool) string {
	var buf bytes.Buffer
	if self {
		html.Render(&buf, n)
	} else {
		for n := n.FirstChild; n != nil; n = n.NextSibling {
			html.Render(&buf, n)
		}
	}
	return buf.String()
}
1208745
func (c Category) RenderHTML(buffer *bytes.Buffer, depth int, maxDepth int) {
	// Check to see if this category is a leaf.
	// A leaf category has no other categories as it's children.
	isLeafCategory := true
	for _, child := range c.children {
		if _, ok := child.(*Category); ok {
			isLeafCategory = false
			break
		}
	}

	if maxDepth > 0 {
		must(fmt.Fprintf(buffer, `<div class="console-column" style="flex: %d">`, c.NumLeafNodes()))
		must(fmt.Fprintf(buffer, `<div class="console-top-item">%s</div>`, template.HTMLEscapeString(c.Name)))
		if isLeafCategory {
			must(fmt.Fprintf(buffer, `<div class="console-top-row console-leaf-category">`))
		} else {
			must(fmt.Fprintf(buffer, `<div class="console-top-row">`))
		}
	}

	for _, child := range c.children {
		child.RenderHTML(buffer, depth+1, maxDepth)
	}

	if maxDepth > 0 {
		must(buffer.WriteString(`</div></div>`))
	}
}
937247
func (d *Dataset) Tabular(format string) *Exportable {
	back := d.Records()
	t := gotabulate.Create(back)

	if format == TabularCondensed || format == TabularMarkdown {
		rendered := regexp.MustCompile("\n\n\\s").ReplaceAllString(t.Render("simple"), "\n ")
		if format == TabularMarkdown {
			firstLine := regexp.MustCompile("-\\s+-").ReplaceAllString(strings.Split(rendered, "\n")[0], "- | -")
			// now just locate the position of pipe characterds, and set them
			positions := make([]int, 0, d.cols-1)
			x := 0
			for _, c := range firstLine {
				if c == '|' {
					positions = append(positions, x)
				}
				x += utf8.RuneLen(c)
			}

			b := newBuffer()
			lines := strings.Split(rendered, "\n")
			for _, line := range lines[1 : len(lines)-2] {
				ipos := 0
				b.WriteString("| ")
				for _, pos := range positions {
					if ipos < len(line) && pos < len(line) {
						b.WriteString(line[ipos:pos])
						b.WriteString(" | ")
						ipos = pos + 1
					}
				}
				if ipos < len(line) {
					b.WriteString(line[ipos:])
				}
				b.WriteString(" | \n")
			}
			return newExportable(b)
		}
		return newExportableFromString(rendered)
	}
	return newExportableFromString(t.Render(format))
}
1342383
func (t *TemplateRenderable) RenderHTML(_ ...string) template.HTML {
	return template.HTML(t.Render())
}
416333
func (j JSON) Render(w io.Writer, v interface{}) error {
	if j.StreamingJSON {
		return j.renderStreamingJSON(w, v)
	}

	var result []byte
	var err error

	if j.Indent {
		result, err = json.MarshalIndent(v, "", "  ")
		result = append(result, '\n')
	} else {
		result, err = json.Marshal(v)
	}
	if err != nil {
		return err
	}

	// Unescape HTML if needed.
	if j.UnEscapeHTML {
		result = bytes.Replace(result, []byte("\\u003c"), []byte("<"), -1)
		result = bytes.Replace(result, []byte("\\u003e"), []byte(">"), -1)
		result = bytes.Replace(result, []byte("\\u0026"), []byte("&"), -1)
	}

	// JSON marshaled fine, write out the result.
	if hw, ok := w.(http.ResponseWriter); ok {
		j.Head.Write(hw)
	}
	if len(j.Prefix) > 0 {
		w.Write(j.Prefix)
	}
	w.Write(result)
	return nil
}
150284
func (s *Selection) BeforeHtml(html string) *Selection {
	return s.BeforeNodes(parseHtml(html)...)
}
718942
func (s *Separator) Render(style *renderStyle) string {
	// loop over getting dashes
	parts := []string{}
	for i := 0; i < style.columns; i++ {
		w := style.PaddingLeft + style.CellWidth(i) + style.PaddingRight
		parts = append(parts, strings.Repeat(style.BorderX, w))
	}

	switch s.where {
	case LINE_TOP:
		return style.BorderTopLeft + strings.Join(parts, style.BorderTop) + style.BorderTopRight
	case LINE_SUBTOP:
		return style.BorderLeft + strings.Join(parts, style.BorderTop) + style.BorderRight
	case LINE_BOTTOM:
		return style.BorderBottomLeft + strings.Join(parts, style.BorderBottom) + style.BorderBottomRight
	case LINE_INNER:
		return style.BorderLeft + strings.Join(parts, style.BorderI) + style.BorderRight
	}
	panic("not reached")
}
619703
func HTMLLine(d *DiffSolution) (string, string) {
	a := &bytes.Buffer{}
	b := &bytes.Buffer{}
	for _, word := range d.Lines {
		switch LineSource(word[2]) {
		case LineFromA:
			span.Execute(a, elem{"w-add", word[0]})
			span.Execute(b, elem{"w-del", ""})
		case LineFromB:
			span.Execute(a, elem{"w-del", ""})
			span.Execute(b, elem{"w-add", word[1]})
		case LineFromBothEdit:
			span.Execute(a, elem{"w-edit", word[0]})
			span.Execute(b, elem{"w-edit", word[1]})
		case LineFromBoth:
			a.WriteString(template.HTMLEscapeString(word[0]))
			b.WriteString(template.HTMLEscapeString(word[1]))
		}
	}
	return a.String(), b.String()
}
472291
func (t *Table) Render() string {
	// Elements is already populated with row data.
	switch t.outputMode {
	case outputTerminal:
		return t.renderTerminal()
	case outputMarkdown:
		return t.renderMarkdown()
	case outputHTML:
		return t.RenderHTML()
	default:
		panic("unknown output mode set")
	}
}