code: private boolean isHtml() {
          StaplerRequest req = Stapler.getCurrentRequest();
          return req!=null && req.getAttribute("html")!=null;
      }
docs: For reusing code between text/html and text/plain, we run them both through the same code path
  and use this request attribute to differentiate.