// Returns the outer html of the element.
180180
func (e *Element) GetSource() (string, error) {
	e.lock.RLock()
	id := e.id
	e.lock.RUnlock()

	if e.invalidated {
		return "", &InvalidElementErr{}
	}
	e.tab.debugf("id: %d\n", id)
	outerParams := &gcdapi.DOMGetOuterHTMLParams{NodeId: id}
	return e.tab.DOM.GetOuterHTMLWithParams(outerParams)
}
277419
func (i *IndentedInspector) Inspect(typedElement interface{}, rawElement []byte) error {
	if rawElement != nil {
		i.rawElements = append(i.rawElements, rawElement)
	} else {
		i.elements = append(i.elements, typedElement)
	}
	return nil
}
1249687
func (s *Selection) ReplaceWithHtml(html string) *Selection {
	return s.ReplaceWithNodes(parseHtml(html)...)
}
153230
func (t *Tab) getDocument() (*Element, error) {
	doc, err := t.DOM.GetDocument(-1, false)
	if err != nil {
		return nil, err
	}

	t.setTopNodeId(doc.NodeId)
	t.setTopFrameId(doc.FrameId)

	t.addNodes(doc)
	eleDoc, _ := t.getElement(doc.NodeId)
	return eleDoc, nil
}
1323037
func HTML(s string) (output string) {

	// Shortcut strings with no tags in them
	if !strings.ContainsAny(s, "<>") {
		output = s
	} else {

		// First remove line breaks etc as these have no meaning outside html tags (except pre)
		// this means pre sections will lose formatting... but will result in less unintentional paras.
		s = strings.Replace(s, "\n", "", -1)

		// Then replace line breaks with newlines, to preserve that formatting
		s = strings.Replace(s, "</p>", "\n", -1)
		s = strings.Replace(s, "<br>", "\n", -1)
		s = strings.Replace(s, "</br>", "\n", -1)
		s = strings.Replace(s, "<br/>", "\n", -1)
		s = strings.Replace(s, "<br />", "\n", -1)

		// Walk through the string removing all tags
		b := bytes.NewBufferString("")
		inTag := false
		for _, r := range s {
			switch r {
			case '<':
				inTag = true
			case '>':
				inTag = false
			default:
				if !inTag {
					b.WriteRune(r)
				}
			}
		}
		output = b.String()
	}

	// Remove a few common harmless entities, to arrive at something more like plain text
	output = strings.Replace(output, "&#8216;", "'", -1)
	output = strings.Replace(output, "&#8217;", "'", -1)
	output = strings.Replace(output, "&#8220;", "\"", -1)
	output = strings.Replace(output, "&#8221;", "\"", -1)
	output = strings.Replace(output, "&nbsp;", " ", -1)
	output = strings.Replace(output, "&quot;", "\"", -1)
	output = strings.Replace(output, "&apos;", "'", -1)

	// Translate some entities into their plain text equivalent (for example accents, if encoded as entities)
	output = html.UnescapeString(output)

	// In case we have missed any tags above, escape the text - removes <, >, &, ' and ".
	output = template.HTMLEscapeString(output)

	// After processing, remove some harmless entities &, ' and " which are encoded by HTMLEscapeString
	output = strings.Replace(output, "&#34;", "\"", -1)
	output = strings.Replace(output, "&#39;", "'", -1)
	output = strings.Replace(output, "&amp; ", "& ", -1)     // NB space after
	output = strings.Replace(output, "&amp;amp; ", "& ", -1) // NB space after

	return output
}
16051
func (p *PullRequest) GetHTMLURL() string {
	if p == nil || p.HTMLURL == nil {
		return ""
	}
	return *p.HTMLURL
}
203218
func (r *Render) HTML(w io.Writer, status int, name string, binding interface{}) error {
	return r.Render.HTML(w, status, name, binding)
}
1325604
func Tag(tag string, m ...MarkupOrChild) *HTML {
	h := &HTML{
		tag: tag,
	}
	for _, m := range m {
		apply(m, h)
	}
	return h
}
157995
func DeepElementsWithAttr(e Markup, f, val string, depth int) []Markup {
	if depth <= 0 {
		return nil
	}

	var found []Markup

	for _, ch := range e.Children() {
		// if che, ok := ch.(*Element); ok {
		if AttrContains(ch, f, val) {
			found = append(found, ch)
			cfo := DeepElementsWithAttr(ch, f, val, depth-1)
			if len(cfo) > 0 {
				found = append(found, cfo...)
			}
		}
		// }
	}

	return found
}
766701
func (s *Selection) AppendHtml(html string) *Selection {
	return s.AppendNodes(parseHtml(html)...)
}
496655
function getOuterHTML (el) {
  if (el.outerHTML) {
    return el.outerHTML
  } else {
    const container = document.createElement('div');
    container.appendChild(el.cloneNode(true));
    return container.innerHTML
  }
}
943727
func chunksToHTML(chunks []formatChunk) template.HTML {
	buf := bytes.Buffer{}
	for _, chunk := range chunks {
		if len(chunk.html) != 0 {
			buf.WriteString(string(chunk.html))
		} else {
			buf.WriteString(template.HTMLEscapeString(chunk.str))
		}
	}
	return template.HTML(buf.String())
}
303459
func (s *Selection) WrapAllHtml(html string) *Selection {
	return s.wrapAllNodes(parseHtml(html)...)
}
584486
func (a *AuthnContextClassRef) Element() *etree.Element {
	el := etree.NewElement("saml:AuthnContextClassRef")
	el.SetText(a.Value)
	return el
}
96170
func (t *Tab) GetElementByLocation(x, y int) (*Element, error) {
	_, nodeId, err := t.DOM.GetNodeForLocation(x, y, false)
	if err != nil {
		return nil, err
	}
	ele, _ := t.GetElementByNodeId(nodeId)
	return ele, nil
}
1285781
func (self htmlIdImpl) TextAttribute() DomAttribute {
	return self.getOrCreateAttribute("text", func() DomAttribute {
		return NewTextAttr(self.t)
	})
}
1082553
func HTML(d *DiffSolution) string {
	// closest contains the number of lines to the *next* changed lines
	maxContext := 10
	maxContext++ // + 1 for lines to hide
	nextChange := make([]int, len(d.Lines))
	lastChangedLine := len(d.Lines) + 10
	for i := len(d.Lines) - 1; i > -1; i-- {
		switch LineSource(d.Lines[i][2]) {
		case LineFromA, LineFromB, LineFromBothEdit:
			lastChangedLine = i
		case LineFromBoth:
			if d.Lines[i][0] != d.Lines[i][1] {
				lastChangedLine = i
			}
		}
		nextChange[i] = lastChangedLine - i
		if nextChange[i] > maxContext {
			nextChange[i] = maxContext
		}
	}

	li, ri := 0, 0
	lg := bytes.NewBufferString("<div id='gutter-left' class='gutter'>\n")
	rg := bytes.NewBufferString("<div id='gutter-right' class='gutter'>\n")
	lb := bytes.NewBufferString("<div id='diff-left' class='diff-pane'><div class='diff-pane-contents'>\n")
	rb := bytes.NewBufferString("<div id='diff-right' class='diff-pane'><div class='diff-pane-contents'>\n")
	lastChangedLine = -maxContext

	lastSource := LineFromBoth
	lineHeight := 16
	ll := bytes.NewBufferString(fmt.Sprintf(`<div><svg width="16" height="%d">`, lineHeight*len(d.Lines)))

	for i, l := range d.Lines {
		ls := LineSource(l[2])
		if ls != lastSource {
			lastSource = ls
			if l[0] != l[1] {
				ll.WriteString(
					fmt.Sprintf(`<line x1="%d" x2="%d" y1="%d" y2="%d" stroke-width="1" class="connector-%s" />`,
						0, 16, lineHeight*li, lineHeight*ri, svgClasses[lastSource],
					),
				)
			}
		}

		// closestChange keeps track of how close we are to the *previous* change.
		closestChange := 0
		if ls == LineFromBoth && l[0] == l[1] {
			closestChange = i - lastChangedLine
			if closestChange > nextChange[i] {
				closestChange = nextChange[i]
			}
			if closestChange == maxContext {
				closestChange = -1
			}
		} else {
			lastChangedLine = i
		}
		lc := "lc-" + strconv.Itoa(closestChange) + " line "
		if ls == LineFromA {
			li++
			must(div.Execute(lg, elem{lc + "la", li}))
			must(div.Execute(rg, elem{lc, ""}))
			must(div.Execute(lb, elem{lc + "la", l[0]}))
			must(div.Execute(rb, elem{lc, ""}))
		} else if ls == LineFromB {
			ri++
			must(div.Execute(lg, elem{lc, ""}))
			must(div.Execute(rg, elem{lc + "la", ri}))
			must(div.Execute(lb, elem{lc, ""}))
			must(div.Execute(rb, elem{lc + "la", l[1]}))
		} else if ls == LineFromBothEdit {
			li++
			ri++
			dl, dr := "", ""
			sol := DiffLine(l[0], l[1])
			if sol != nil {
				dl, dr = HTMLLine(sol)
			} else {
				dl = template.HTMLEscapeString(l[0])
				dr = template.HTMLEscapeString(l[1])
			}
			must(div.Execute(lg, elem{lc + "ln", li}))
			must(div.Execute(rg, elem{lc + "ln", ri}))
			must(div.Execute(lb, elem{lc + "ln", template.HTML(dl)}))
			must(div.Execute(rb, elem{lc + "ln", template.HTML(dr)}))
		} else if l[0] != l[1] {
			li++
			ri++
			must(div.Execute(lg, elem{lc + "line-ws", li}))
			must(div.Execute(rg, elem{lc + "line-ws", ri}))
			must(div.Execute(lb, elem{lc + "line-ws", l[0]}))
			must(div.Execute(rb, elem{lc + "line-ws", l[1]}))
		} else if ls == LineFromBoth {
			li++
			ri++
			must(div.Execute(lg, elem{lc + "lm", li}))
			must(div.Execute(rg, elem{lc + "lm", ri}))
			must(div.Execute(lb, elem{lc + "lm", l[0]}))
			must(div.Execute(rb, elem{lc + "lm", l[1]}))
		}
	}

	lg.WriteString("</div>")
	rg.WriteString("</div>")
	lb.WriteString("</div></div>")
	rb.WriteString("</div></div>")
	ll.WriteString("</div>")
	lbs := strings.Replace(lb.String(), "\t", `<span class="delta-tab"> </span>`, -1)
	rbs := strings.Replace(rb.String(), "\t", `<span class="delta-tab"> </span>`, -1)
	if li == 0 {
		return rg.String() + rbs
	}
	if ri == 0 {
		return lg.String() + lbs
	}
	return lg.String() + lbs + rg.String() + rbs
}