code: public void transfromHeadline()
      {
          if (this.hlDepth > 0)
          {
              return;
          }
          int level = 0;
          final Line line = this.lines;
          if (line.isEmpty)
          {
              return;
          }
          int start = line.leading;
          while (start < line.value.length() && line.value.charAt(start) == '#')
          {
              level++;
              start++;
          }
          while (start < line.value.length() && line.value.charAt(start) == ' ')
          {
              start++;
          }
          if (start >= line.value.length())
          {
              line.setEmpty();
          }
          else
          {
              int end = line.value.length() - line.trailing - 1;
              while (line.value.charAt(end) == '#')
              {
                  end--;
              }
              while (line.value.charAt(end) == ' ')
              {
                  end--;
              }
              line.value = line.value.substring(start, end + 1);
              line.leading = line.trailing = 0;
          }
          this.hlDepth = Math.min(level, 6);
      }
docs: Sets <code>hlDepth</code> and takes care of '#' chars.