コード例 #1
0
ファイル: StringExtensions.java プロジェクト: kalpakrg/sole
 public static String md(Object obj) {
   String retVal = obj.toString();
   try {
     StringBuffer buff = new StringBuffer();
     Markdown md = new Markdown();
     Reader in = new StringReader(obj.toString());
     Writer out = new StringBufferWriter(buff);
     md.transform(in, out);
     out.flush();
     retVal = buff.toString();
     retVal = HtmlSanitizer.clean(retVal);
   } catch (Exception e) {
     String msg = "Could not parse for markdown '" + obj.toString() + "'";
     cLogger.error(msg, e);
   }
   return retVal;
 }
コード例 #2
0
  public static String renderMarkdown2(String text) {
    // 协议替换
    text = replayProctoct(text);
    // 转换
    StringWriter out = new StringWriter();
    try {
      md.transform(new StringReader(text), out);
      text = out.toString();

      // 生成完整html
      return text;
    } catch (ParseException e) {
      return text;
    }
  }
コード例 #3
0
  public static String renderMarkdown(String text) {
    text = replayProctoct(text);
    // 转换
    StringWriter out = new StringWriter();
    try {
      md.transform(new StringReader(text), out);
      text = out.toString();

      // 生成完整html
      return HTML_0
          + "\n<link type=\"text/css\" rel=\"stylesheet\" href=\""
          + THEME_CSS
          + "\">"
          + HTML_1
          + text
          + HTML_2;
    } catch (ParseException e) {
      return text;
    }
  }