예제 #1
0
 public static String generateDoc(
     @Nullable final String signature,
     final boolean signatureIsHtml,
     @Nullable final String docText,
     @Nullable final String containingLibraryName,
     @Nullable final String containingClassDescription,
     @Nullable final String staticType,
     @Nullable final String propagatedType) {
   final boolean hasContainingLibraryName = !StringUtil.isEmpty(containingLibraryName);
   final boolean hasContainingClassDescription = !StringUtil.isEmpty(containingClassDescription);
   final boolean hasStaticType = !StringUtil.isEmpty(staticType);
   final boolean hasPropagatedType = !StringUtil.isEmpty(propagatedType);
   // generate
   final StringBuilder builder = new StringBuilder();
   builder.append("<code>");
   if (signature != null) {
     builder.append("<b>Signature:</b> ");
     if (signatureIsHtml) {
       builder.append(signature);
     } else {
       builder.append(StringUtil.escapeXml(signature));
     }
     builder.append("<br>");
   }
   if (hasContainingLibraryName || hasContainingClassDescription) {
     builder.append("<br>");
     if (hasContainingLibraryName) {
       builder.append("<b>Containing library:</b> ");
       builder.append(StringUtil.escapeXml(containingLibraryName));
       builder.append("<br>");
     }
     if (hasContainingClassDescription) {
       builder.append("<b>Containing class:</b> ");
       builder.append(StringUtil.escapeXml(containingClassDescription));
       builder.append("<br>");
     }
   }
   if (hasStaticType || hasPropagatedType) {
     builder.append("<br>");
     if (hasStaticType) {
       builder.append("<b>Static type:</b> ");
       builder.append(StringUtil.escapeXml(staticType));
       builder.append("<br>");
     }
     if (hasPropagatedType) {
       builder.append("<b>Propagated type:</b> ");
       builder.append(StringUtil.escapeXml(propagatedType));
       builder.append("<br>");
     }
   }
   builder.append("</code>");
   if (docText != null) {
     builder.append("<br>");
     final MarkdownProcessor processor = new MarkdownProcessor();
     builder.append(processor.markdown(docText));
   }
   // done
   return builder.toString();
 }
 private void loadMarkdownToView(String txt, String cssFileUrl) {
   MarkdownProcessor m = new MarkdownProcessor();
   String html = m.markdown(txt);
   if (cssFileUrl != null) {
     /*
     html = String.format(
     		"<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />"
     				+ html, cssFileUrl);
     				*/
     // TODO 原来的实现如果html中包含正则会报错
     html = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssFileUrl + "\" />" + html;
   }
   loadDataWithBaseURL("fake://", html, "text/html", "UTF-8", null);
 }
예제 #3
0
 @Override
 public void run(String value, Doc doc, Model model, ValidationResult validationResult) {
   Format format = (Format) validationResult.getData();
   switch (format) {
     case MARKDOWN:
       doc.setText(markdown.markdown(stripIndentation(doc.getText())));
       break;
   }
 }