like textToHtml but escapes double quotes to be attribute safe.
964283
function attribToHtml(str) {
    return str.replace(pr_amp, '&amp;')
        .replace(pr_lt, '&lt;')
        .replace(pr_gt, '&gt;')
        .replace(pr_quot, '&quot;');
  }
478362
function _escapeHtml (input) {
  return String(input)
   .replace(/&/g, '&amp;')
   .replace(/</g, '&lt;')
   .replace(/>/g, '&gt;')
   .replace(/"/g, '&quot;')
   .replace(/'/g, '&#039;');
 }
872944
@Transformer
    public static RawData escapeHTML(Object o) {
        if (null == o) return RawData.NULL;
        if (o instanceof RawData) {
            return (RawData) o;
        }
        return new RawData(StringEscapeUtils.escapeHtml4(o.toString()));
    }
183365
function getAttributeQuote(editor, attr) {
	const range = new Range(attr.value ? attr.value.end : attr.end, attr.end);
	return range.isEmpty() ? '' : editor.getTextInBufferRange(range);
}
215926
function escapeXml (string) {
    return String(string).replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  }
1085784
function () {
        var formatter = Description.format[_.isString(this.type) && this.type.toLowerCase()];
        return (formatter ? formatter : escapeHtml)(this.content || E);
    }
1038613
public static String escapeAttributeValue(String s) {
        s = cleanWS(s);
        s = replaceAll(s, BackSlashPtn, EscBackSlash);
        s = replaceAll(s, SemicolonPtn, EscSemicolon);
        s = replaceAll(s, RParenPtn, EscRParen);
        return s;
    }
279817
function processHtmlAttributes(input = {}) {
    const attributes = {};
    const htmlAttributes = input.htmlAttributes;
    const wildcardAttributes = input['*'];

    let obj = htmlAttributes || wildcardAttributes;
    if (htmlAttributes && wildcardAttributes) {
        obj = Object.assign(wildcardAttributes, htmlAttributes);
    }

    if (obj) {
        Object.keys(obj).forEach((key) => {
            attributes[camelToKebab(key)] = obj[key];
        });
    }

    return attributes;
}
199850
function(attr) {
        var html = this._escapedAttributes[attr];
        if (html) {
          return html;
        }
        var val = this.attributes[attr];
        var escaped;
        if (isNullOrUndefined(val)) {
          escaped = '';
        } else {
          escaped = _.escape(val.toString());
        }
        this._escapedAttributes[attr] = escaped;
        return escaped;
      }
1290331
function(attr) {
      var html;
      if (html = this._escapedAttributes[attr]) return html;
      var val = this.attributes[attr];
      return this._escapedAttributes[attr] = escapeHTML(val == null ? '' : '' + val);
    }
355192
def escape(string, quote=False):
    
    if string is None:
        return ''
    elif hasattr(string, '__html__'):
        return unicode(string)
    string = string.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
    if quote:
        string = string.replace('"', "&quot;")
    return string
937486
public static String escapeAttributeValue(Object value, Context cx)
    {
        XMLLib xmlLib = currentXMLLib(cx);
        return xmlLib.escapeAttributeValue(value);
    }
1353193
function (attr, expr, context, data) {
                var val = this.exprEvaluator(expr, context, data);
                if (val || typeof val === 'string' || typeof val === 'number') {
                    return " " + attr + '=' + this.generateAttribute(val + '');
                } else {
                    //else if undefined, null, false then don't render attribute.
                    return '';
                }
            }
267933
public static String escapeHtmlAttributeNospace(SoyValue value) {
    value = normalizeNull(value);
    if (isSanitizedContentOfKind(value, SanitizedContent.ContentKind.HTML)) {
      // |escapeHtmlAttributeNospace should only be used on attribute values that cannot have tags.
      return stripHtmlTags(value.coerceToString(), null, false);
    }
    return escapeHtmlAttributeNospace(value.coerceToString());
  }
1104644
function escapeStringForJavascript(content) {
  return content.replace(/(['\\])/g, '\\$1')
    .replace(/[\f]/g, "\\f")
    .replace(/[\b]/g, "\\b")
    .replace(/[\n]/g, "\\n")
    .replace(/[\t]/g, "\\t")
    .replace(/[\r]/g, "\\r")
    .replace(/[\u2028]/g, "\\u2028")
    .replace(/[\u2029]/g, "\\u2029");
}
585383
def escape(html):
    
    from yacms.conf import settings
    from yacms.core import defaults
    if settings.RICHTEXT_FILTER_LEVEL == defaults.RICHTEXT_FILTER_LEVEL_NONE:
        return html
    tags = settings.RICHTEXT_ALLOWED_TAGS
    attrs = settings.RICHTEXT_ALLOWED_ATTRIBUTES
    styles = settings.RICHTEXT_ALLOWED_STYLES
    if settings.RICHTEXT_FILTER_LEVEL == defaults.RICHTEXT_FILTER_LEVEL_LOW:
        tags += LOW_FILTER_TAGS
        attrs += LOW_FILTER_ATTRS
    return clean(html, tags=tags, attributes=attrs, strip=True,
                 strip_comments=False, styles=styles)
320346
def htmlquote(text):
    
    """
    text = text.replace(u"&", u"&amp;") # Must be done first!
    text = text.replace(u"<", u"&lt;")
    text = text.replace(u">", u"&gt;")
    text = text.replace(u"'", u"&#39;")
    text = text.replace(u'"', u"&quot;")
    return text