@@ -0,0 +1,2426 @@
+#!/usr/bin/env python%0A%0Aimport codecs%0Aimport os.path%0Afrom StringIO import StringIO%0A%0Adef convert_md_file(src_file, dest_file):%0A    srcf = codecs.open(src_file, 'rb', 'utf-8')%0A    in_memory = False%0A    if os.path.abspath(src_file) == os.path.abspath(dest_file):%0A        outf = StringIO()%0A        in_memory = True%0A    else:%0A        outf = codecs.open(dest_file, 'wb', 'utf-8')%0A    in_codeblock = False%0A    for line in srcf:%0A        striped_line = line.strip(' %5Ct%5Cn')%0A        if striped_line == '%7B%25 include JB/setup %25%7D':%0A            continue%0A        if striped_line.startswith('%7B%25 highlight'):%0A            lang = None%0A            parts = striped_line.split(' ')%0A            if len(parts) == 4:%0A                lang = parts%5B2%5D%0A            outf.write(lang and '%7B%25%25 codeblock lang:%25s %25%25%7D%5Cn'%25(lang,) or '%7B%25 codeblock %25%7D%5Cn')%0A            continue%0A        if striped_line == '%7B%25 endhighlight %25%7D':%0A            outf.write('%7B%25 endcodeblock %25%7D%5Cn')%0A            continue%0A        if line.startswith('    :::') and not in_codeblock:%0A            in_codeblock = True%0A            codeblock_lines = %5B%5D%0A            lang = striped_line%5B3:%5D%0A            outf.write(lang and '%7B%25%25 codeblock lang:%25s %25%25%7D%5Cn'%25(lang,) or '%7B%25 codeblock %25%7D%5Cn')%0A        elif in_codeblock:%0A            if line.startswith('    '):%0A                codeblock_lines.append(line%5B4:%5D)%0A            elif len(striped_line) == 0:%0A                codeblock_lines.append('%5Cn')%0A            else:%0A                i = 0%0A                while codeblock_lines%5B-1%5D == '%5Cn':%0A                    del codeblock_lines%5B-1%5D%0A                    i += 1%0A                for ln in codeblock_lines:%0A                    outf.write(ln)%0A                outf.write('%7B%25 endcodeblock %25%7D%5Cn')%0A                outf.write('%5Cn' * i)%0A                in_codeblock = False%0A                codeblock_lines = %5B%5D%0A                outf.write(line)%0A        else:%0A            outf.write(line)%0A    srcf.close()%0A    if in_memory:%0A        wf = codecs.open(dest_file, 'wb', 'utf-8')%0A        wf.write(outf.getvalue())%0A        outf.close()%0A        wf.close()%0A    else:%0A        outf.close()%0A%0Adef convert_all_under_folder(folder_path):%0A    import glob%0A    import os.path%0A    flist = glob.glob(os.path.join(folder_path, '*.md'))%0A    for f in flist:%0A        convert_md_file(f, f)%0A%0Aif __name__ == '__main__':%0A    #convert_md_file('test.md', 'test2.md')%0A    convert_all_under_folder('/home/vika/development/nodejs/hexo_blog/source/_posts')%0A%0A%0A%0A

add convert markdown post file