@Override
 public void onComponentTagBody(MarkupStream markup, ComponentTag tag) {
   // We assume the body of the component is raw HTML
   // (i.e. not nested wicket components or wicket tags).
   RawMarkup raw = (RawMarkup) markup.get();
   getResponse().write(getTruncateHelper().truncate(raw.toString(), this.length));
   markup.next();
 }
  /**
   * Process next header markup fragment.
   *
   * @param associatedMarkupStream
   * @return index or -1 when done
   */
  private int nextHeaderMarkup(final MarkupStream associatedMarkupStream) {
    // No associated markup => no header section
    if (associatedMarkupStream == null) {
      return -1;
    }

    // Scan the markup for <wicket:head>.
    MarkupElement elem = associatedMarkupStream.get();
    while (elem != null) {
      if (elem instanceof WicketTag) {
        WicketTag tag = (WicketTag) elem;
        if (tag.isOpen() && tag.isHeadTag()) {
          if (noMoreWicketHeadTagsAllowed == true) {
            throw new MarkupException(
                "<wicket:head> tags are only allowed before <body>, </head>, <wicket:panel> etc. tag");
          }
          return associatedMarkupStream.getCurrentIndex();
        }
        // wicket:head must be before border, panel or extend
        // @TODO why is that? Why can't it be anywhere? (except inside wicket:fragment)
        else if (tag.isOpen() && (tag.isPanelTag() || tag.isBorderTag() || tag.isExtendTag())) {
          noMoreWicketHeadTagsAllowed = true;
        }
      } else if (elem instanceof ComponentTag) {
        ComponentTag tag = (ComponentTag) elem;
        // wicket:head must be before </head>
        // @TODO why??
        if (tag.isClose() && TagUtils.isHeadTag(tag)) {
          noMoreWicketHeadTagsAllowed = true;
        }
        // wicket:head must be before <body>
        // @TODO why??
        else if (tag.isOpen() && TagUtils.isBodyTag(tag)) {
          noMoreWicketHeadTagsAllowed = true;
        }
      }
      elem = associatedMarkupStream.next();
    }

    // No (more) wicket:head found
    return -1;
  }