code: function iterateBidiSections(order, from, to, f) {
      if (!order) return f(from, to, "ltr");
      var found = false;
      for (var i = 0; i < order.length; ++i) {
        var part = order[i];
        if (part.from < to && part.to > from || from == to && part.to == from) {
          f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr");
          found = true;
        }
      }
      if (!found) f(from, to, "ltr");
    }
docs: BIDI HELPERS