Escape things that need to be escaped if they're in a cross-reference.
338937
def _escape_xref(xref_match):
    
    xref = xref_match.group()
    xref = xref.replace('/', '%2F')
    xref = xref.replace('?', '%3F')
    xref = xref.replace('#', '%23')
    return xref
77999
def replaceStrs(s, *args):
    

    """
    if args == (): return s
    mapping = dict((frm, to) for frm, to in args)
    return re.sub("|".join(map(re.escape, mapping.keys())),
                  lambda match:mapping[match.group(0)], s)
715707
function traverseReplace(node, parent, scope, remaps) {
  if (t.isIdentifier(node)) {
    replace(node, parent, scope, remaps);
  }

  if (t.isAssignmentExpression(node)) {
    var ids = t.getBindingIdentifiers(node);
    for (var name in ids) {
      replace(ids[name], parent, scope, remaps);
    }
  }

  scope.traverse(node, replaceVisitor, remaps);
}
1098131
def do_pass(self, element, decl, pseudo):
        """"""
        log(WARN, u"Old-style pass as declaration not allowed.{}"
            .format(decl.value).encpde('utf-8'))
630189
function removeReference(name, opposite) {
  const ref = this.references[name]
  _.unset(this.references, name)
  if (ref.opposite !== undefined) {
    if (opposite) {
      _.unset(ref.type.references, ref.opposite)
    } else {
      _.unset(ref.type.references[ref.opposite], 'opposite')
    }
  }
}
184955
def exclude(source, keys, *, transform=None):
  
  check = keys if callable(keys) else lambda key: key in keys
  return {key: transform(source[key]) if transform else source[key]
          for key in source if not check(key)}
366105
def coerce(cls, key, value):
        """"""
        if value is None:
            return value
        if isinstance(value, cls):
            return value
        if isinstance(value, dict):
            return NestedMutableDict.coerce(key, value)
        if isinstance(value, list):
            return NestedMutableList.coerce(key, value)
        return super(cls).coerce(key, value)
1133567
def _surface_escape(code, char):
        
        replacement = str(HTMLEntity(value=ord(char)))
        for node in code.filter_text(recursive=False):
            if char in node:
                code.replace(node, node.replace(char, replacement), False)
463712
function SanitizeCtx(ctx) {
  let r = {};
  for (const key in ctx) {
    if (!key.startsWith('_')) {
      r[key] = ctx[key];
    }
  }
  return r;
}
791285
def escape_chars(text, chars):
    """"""
    text = str(text)
    chars = list(set(chars))
    if '\\' in chars:
        chars.remove('\\')
        chars.insert(0, '\\')
    for ch in chars:
        text = text.replace(ch, '\\' + ch)
    return text
1310866
def _remove_brackets(x, i):
    """"""

    assert x[i]['t'] == 'Cite'
    assert i > 0 and i < len(x) - 1

    # Check if the surrounding elements are strings
    if not x[i-1]['t'] == x[i+1]['t'] == 'Str':
        return

    # Trim off curly brackets
    if x[i-1]['c'].endswith('{') and x[i+1]['c'].startswith('}'):
        if len(x[i+1]['c']) > 1:
            x[i+1]['c'] = x[i+1]['c'][1:]
        else:
            del x[i+1]

        if len(x[i-1]['c']) > 1:
            x[i-1]['c'] = x[i-1]['c'][:-1]
        else:
            del x[i-1]
1253023
def remove_value(self, name):
        """"""
        ns = self._get_reference_namespace(name)
        ns.pop(name)
890747
def _unescape(v):
    """"""
    i = 0
    backslash = False
    while i < len(v):
        if backslash:
            backslash = False
            if v[i] in _escapes:
                v = v[:i - 1] + _escape_to_escapedchars[v[i]] + v[i + 1:]
            elif v[i] == '\\':
                v = v[:i - 1] + v[i:]
            elif v[i] == 'u' or v[i] == 'U':
                i += 1
            else:
                raise TomlDecodeError("Reserved escape sequence used")
            continue
        elif v[i] == '\\':
            backslash = True
        i += 1
    return v
574775
def compat_kwargs(kwargs):
    """"""
    warn_deprecations(kwargs)
    for old, new in RENAMED_VARS.items():
        if old in kwargs:
            kwargs[new] = kwargs[old]
            # update cross references
            for c_old, c_new in RENAMED_VARS.items():
                if c_new == new:
                    kwargs[c_old] = kwargs[new]
5057
function handleFindRefs (refsResp) {
            if (!refsResp || !refsResp.references || !refsResp.references.refs) {
                return;
            }

            var inlineWidget = EditorManager.getFocusedInlineWidget(),
                editor = EditorManager.getActiveEditor(),
                refs = refsResp.references.refs,
                type = refsResp.references.type;

            //In case of inline widget if some references are outside widget's text range then don't allow for rename
            if (inlineWidget) {
                var isInTextRange  = !refs.find(function(item) {
                    return (item.start.line < inlineWidget._startLine || item.end.line > inlineWidget._endLine);
                });
                
                if (!isInTextRange) {
                    editor.displayErrorMessageAtCursor(Strings.ERROR_RENAME_QUICKEDIT);
                    return;
                }
            }

            var currentPosition = editor.posFromIndex(refsResp.offset),
                refsArray = refs;
            if (type !== "local") {
                refsArray = refs.filter(function (element) {
                    return isInSameFile(element, refsResp);
                });
            }

            // Finding the Primary Reference in Array
            var primaryRef = refsArray.find(function (element) {
                return ((element.start.line === currentPosition.line || element.end.line === currentPosition.line)
                        && currentPosition.ch <= element.end.ch && currentPosition.ch >= element.start.ch);
            });
            // Setting the primary flag of Primary Refence to true
            primaryRef.primary = true;

            editor.setSelections(refsArray);
        }
445885
def quote(s, unsafe='/'):
    """"""
    res = s.replace('%', '%25')
    for c in unsafe:
        res = res.replace(c, '%' + (hex(ord(c)).upper())[2:])
    return res
79032
def escape(cls, s):
        
        rv = escape(s)
        if rv.__class__ is not cls:
            return cls(rv)
        return rv