<commit_before>(function ( $ ) {


  $.fn.textPerc = function( options ) {

    // Let's set our default settings
    var settings = $.extend({}, this.defaults, options );

    return this.each(function() {
      var
      elem = this,
      $elem = $(this),
      starting_size = 9;
      

      // Preparation is key.
      setup( $elem, starting_size );      

      // It's variable time! Let's figure out who the major players are.
      var
      container         = $elem.parent(),
      container_width   = container.width(),
      text_width        = $elem.width(),
      text_width_ratio  = text_width / container_width,
      font_increment    = 0.1;



      // Time to do our thing. This happens in two main parts. 

      // Part I: Broad Strokes.
      // We do some math to get what ought to be the perfect font size, and substract 1.
      var broad_font_size = broad_strokes( $elem, starting_size, text_width_ratio);
      // This is guaranteed to be anywhere from juuuuust about perfect, to significantly too small.

      // Part II: Incremental Increases.
      // We're going to keep augmenting the font size by tiny increments, up to the point that it causes
      // the header to split into 2 lines. Then, we'll revert the last change, getting the perfect font size.
      var 
      starting_height      = $elem.height(),
      increasing_font_size = broad_font_size;

      console.log(increasing_font_size);

      while ( $elem.height() < starting_height * 2 ) {
        increasing_font_size += font_increment;
        $elem.css("font-size", increasing_font_size);
        console.log(increasing_font_size);
      }

      // We've gone one step too far. Let's undo that last iteration and call it a day!
      increasing_font_size -= font_increment;
      $elem.css("font-size", increasing_font_size);

      // Gotta wash some dishes
      cleanup( $elem );



      // Testing function.
      debug( this );

    });
  }

  // Our setup function. Does a few quick things to get our text ready.
  function setup( $elem, starting_size ) {
    // First, we set the text element (whether it's an h2 or a p or a div) to display: inline;.
    // This is done so that we can find out how much width the letters themselves take up.
    $elem.css("display", "inline");

    // Next, we shrink the text down to mini-size. 
    // This is done because when we retrieve the header's width, we want to make sure it fits on 1 line.
    $elem.css("font-size", starting_size);
  }

  // Does some quick and dirty cross multiplication to get a good starting-point font size.
  function broad_strokes( $elem, starting_size, text_width_ratio ) {
    var new_font_size = Math.floor(starting_size / text_width_ratio);
<commit_msg>Muahahaha, works perfectly.<commit_after>(function ( $ ) {


  $.fn.textPerc = function( options ) {

    // Let's set our default settings
    var settings = $.extend({}, this.defaults, options );

    return this.each(function() {
      var
      elem = this,
      $elem = $(this),
      starting_size = 9;
      

      // Preparation is key.
      setup( $elem, starting_size );      

      // It's variable time! Let's figure out who the major players are.
      var
      container         = $elem.parent(),
      container_width   = container.width(),
      text_width        = $elem.width(),
      text_width_ratio  = text_width / container_width;



      // Time to do our thing. This happens in two main parts. 

      // Part I: Broad Strokes.
      // We do some math to get what ought to be the perfect font size. This will work most times.
      var broad_font_size = broad_strokes( $elem, starting_size, text_width_ratio);
      $elem.css("font-size", broad_font_size);

      // Part II: Incremental Increases.
      // There are times where it might choose a font size that is a little too small.
      // We'll increment it until we KNOW we've gone too far, and then reduce it by 1.
      var 
      starting_height      = $elem.height(),
      increasing_font_size = broad_font_size;

      console.log("Our initial font size is " + increasing_font_size);
      console.log("Our 'while' condition is that " + $elem.height() + " must be less than " + starting_height*2 + " (which is " + starting_height + " times 2)");

      while ( $elem.height() < starting_height * 2 ) {
        increasing_font_size++;
        $elem.css("font-size", increasing_font_size);
        console.log(increasing_font_size);
        console.log("height is " + $elem.height() );
      }

      // We've gone one step too far. Let's undo that last iteration and call it a day!
      increasing_font_size--;
      $elem.css("font-size", increasing_font_size);

      // Gotta wash some dishes
      cleanup( $elem );



      // Testing function.
      debug( this );

    });
  }

  // Our setup function. Does a few quick things to get our text ready.
  function setup( $elem, starting_size ) {
    // First, we set the text element (whether it's an h2 or a p or a div) to display: inline;.
    // This is done so that we can find out how much width the letters themselves take up.
    $elem.css("display", "inline");

    // Next, we shrink the text down to mini-size. 
    // This is done because when we retrieve the header's width, we want to make sure it fits on 1 line.
    $elem.css("font-size", starting_size);
  }

  // Does some quick and dirty cross multiplication to get a good starting-point font size.
  function broad_strokes( $elem, starting_size, text_width_ratio ) {
    var new_font_size = Math.floor(starting_size / text_width_ratio);

{'fraction_non_alphanumeric': 0.0998927805575411, 'fraction_numerical': 0.0026804860614724805, 'mean_word_length': 2.467781908302354, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2590373', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1559, 'n_words': 604}