package com.commonsware.cwac.anddown;

public class AndDown {
  static {
    System.loadLibrary("anddown");
  }

  // extension flags for markdown rendering (see document.h for detail)
  // no extensions
  public static final int FLAG_EXTENSIONS_NONE = 0;
  // basic extensions set: tables(bit 0), autolink(bit 3), strike through(bit 4), underline(bit 5)
  public static final int FLAG_EXTENSIONS_BASIC = 0x39;
  // medium extensions set: fenced code(bit 1), highlight(bit 6), quote(bit 7), superscript(bit 8)
  public static final int FLAG_EXTENSIONS_MEDIUM = FLAG_EXTENSIONS_BASIC | 0x1c2;
  // advance extensions set: footnotes(bit 2), math(bit 9)
  public static final int FLAG_EXTENSIONS_ADVANCE = FLAG_EXTENSIONS_MEDIUM | 0x204;

  // Disable emphasis_between_words(bit 11)
  public static final int FLAG_NO_INTRA_EMPHASIS = 1 << 11;
  // Require a space after '#' in headers(bit 12)
  public static final int FLAG_SPACE_HEADERS = 1 << 12;
  // Instead of guessing by context, parse $inline math$ and $$always block math$$(bit 13)
  public static final int FLAG_MATH_EXPLICIT = 1 << 13;
  // Don't parse indented code blocks(bit 14)
  public static final int FLAG_DISABLE_INDENTED_CODE = 1 << 14;

  // default flag for markdown rendering
  public static final int FLAG_DEFAULT = FLAG_EXTENSIONS_NONE;

  public native String markdownToHtml(String raw, int flag);

  public String markdownToHtml(String raw) {
    return markdownToHtml(raw, FLAG_DEFAULT);
  }
}

@@ -725,24 +725,182 @@
 M %7C 0x204;%0A%0A
+  static final int%5B%5D EXTENSIONS_LEVEL = %7B%0A    FLAG_EXTENSIONS_NONE,%0A    FLAG_EXTENSIONS_BASIC,%0A    FLAG_EXTENSIONS_MEDIUM,%0A    FLAG_EXTENSIONS_ADVANCE,%0A  %7D;%0A%0A
   // Disable
@@ -1616,11 +1616,437 @@
 LT);%0A  %7D
+%0A%0A  /**%0A   * convent markdown to html%0A   *%0A   * @raw: markdown in plain text%0A   * @flag: extension flags for markdown rendering%0A   * @level: 0 - none, 1 - basic, 2 - medium, 3 - advance, other value are ignored%0A   */%0A  public String markdownToHtml(String raw, int flag, int level) %7B%0A    if (level %3E= 0 && level %3C EXTENSIONS_LEVEL.length) %7B%0A      flag %7C= EXTENSIONS_LEVEL%5Blevel%5D;%0A    %7D%0A    return markdownToHtml(raw, flag);%0A  %7D
 %0A%7D%0A

make markdownToHtml() more easier