<commit_before>
var ESCAPED_CHARS_UNQUOTED_REGEX = /[&<>]/g;
var ESCAPED_CHARS_QUOTED_REGEX = /[&<>"]/g;

var escapeMap = {
  "<": "&lt;",
  ">": "&gt;",
  "&": "&amp;",
  '"': "&quot;"
};
var escapeOne = function(c) {
  return escapeMap[c];
};

UI.encodeSpecialEntities = function (text, isQuoted) {
  // Encode Unicode characters to HTML entities.
  //
  // This implementation just encodes the characters that otherwise
  // wouldn't parse (like `<`) and passes the rest through.  You'd
  // need to do something different if you care about HTML entities as
  // a way to embed special characters in ASCII.
  return text.replace(isQuoted ? ESCAPED_CHARS_QUOTED_REGEX :
                      ESCAPED_CHARS_UNQUOTED_REGEX, escapeOne);
};


var GT_OR_QUOTE = /[>'"]/;

// Instantiate `comp` with `props` by calling extend, or,
// in the special case where `comp` is an already-inited
// component, just return it.  In this latter case, the
// `props` argument must be falsy.
constructify = function (comp, props) {
  if (! comp)
    throw new Error("No such component");
  if (props)
    // comp had better be uninited! (or will throw)
    return comp.extend(props);
  else if (comp.isInited)
    return comp;
  else
    return comp.extend();
};

makeRenderBuffer = function (component, options) {
  var isPreview = !! options && options.preview;

  var strs = [];
  var componentsToAttach = null; // {}
  var randomString = null; // Random.id()
  var commentUid = 1;
  var elementUid = 1;
  // Problem: In the template `<span {{foo}} {{bar}}>`, how do
  // we make foo and bar insert some HTML in the stream that
  // will allow us to find the element later?  Since we don't
  // tokenize the HTML here, we can't even be sure whether
  // they are in the same tag.  We can't emit a duplicate
  // extra attribute.  We can emit different attributes,
  // but if every attr tag emits a different attribute, it
  // won't be efficient to find them.
  //
  // Solution: Emit different attributes, data-meteorui-id1<commit_msg>more wip<commit_after>
UI.renderTo = function (kind, props,
                        parentNode, beforeNode, parentComp) {
  if (kind === null)
    return;
  if (! UI.isComponent(kind))
    throw new Error("Expected Component, function, or null");
  if (kind.isInited)
    throw new Error("Expected uninited Component");
  // XXX Handle case where kind is function, be reactive
  // about it.  Reuse the same DomRange.

  var comp = kind.extend(props);
  var dom = new DomRange;
  // Insert new DomRange's start/end markers
  var nodes = dom.getNodes();
  for (var i = 0, N = nodes.length; i < N; i++)
    parentNode.insertBefore(nodes[i], beforeNode);

  comp.dom = dom;
  comp.isInited = true;

  if (comp.init)
    comp.init();

  if (comp.render) {
    var buf = makeRenderBuffer(dom);
    comp.render(buf);
    buf.wireUp();
  }
};

var ESCAPED_CHARS_UNQUOTED_REGEX = /[&<>]/g;
var ESCAPED_CHARS_QUOTED_REGEX = /[&<>"]/g;

var escapeMap = {
  "<": "&lt;",
  ">": "&gt;",
  "&": "&amp;",
  '"': "&quot;"
};
var escapeOne = function(c) {
  return escapeMap[c];
};

UI.encodeSpecialEntities = function (text, isQuoted) {
  // Encode Unicode characters to HTML entities.
  //
  // This implementation just encodes the characters that otherwise
  // wouldn't parse (like `<`) and passes the rest through.  You'd
  // need to do something different if you care about HTML entities as
  // a way to embed special characters in ASCII.
  return text.replace(isQuoted ? ESCAPED_CHARS_QUOTED_REGEX :
                      ESCAPED_CHARS_UNQUOTED_REGEX, escapeOne);
};


var GT_OR_QUOTE = /[>'"]/;

makeRenderBuffer = function (range, options) {
  var isPreview = !! options && options.preview;

  var strs = [];
  var componentsToAttach = null; // {}
  var randomString = null; // Random.id()
  var commentUid = 1;
  var elementUid = 1;
  // Problem: In the template `<span {{foo}} {{bar}}>`, how do
  // we make foo and bar insert some HTML in the stream that
  // will allow us to find the element later?  Since we don't
  // tokenize the HTML here, we can't even be sure whether
  // they are in the same tag.  We can't emit a duplicate
  // extra attribute.  We can emit different attributes,
  // but if every attr tag emits a different attribute, it
  // won't be efficient to find them.
  //
  // Solution: Emit different attributes, data-meteorui-id1
{'fraction_non_alphanumeric': 0.12851589297964783, 'fraction_numerical': 0.001600731763091699, 'mean_word_length': 3.0916744621141254, 'pattern_counts': {'":': 6, '<': 14, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3998916', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1402, 'n_words': 496}