From 204f8cd678ba99bea6635649df0feb3abfeb94bd Mon Sep 17 00:00:00 2001 From: Artem Date: Thu, 26 Jun 2008 20:50:26 +0500 Subject: Test suite cleanup. README for markdown2 tests. Separation in two stages(markdown to tree, applying inline patterns). --- tests2/README.txt | 8 ++++++++ tests2/formatter.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tests2/README.txt create mode 100644 tests2/formatter.py (limited to 'tests2') diff --git a/tests2/README.txt b/tests2/README.txt new file mode 100644 index 0000000..443236f --- /dev/null +++ b/tests2/README.txt @@ -0,0 +1,8 @@ +This tests was borrowed from [Python-Markdown2][] implementation. + +Note that php-markdown-cases-new tests is licensed under the [GPL][]. +And tm-cases-new is licensed under the [MIT License][]. + +[Python-Markdown2]: http://code.google.com/p/python-markdown2 +[GPL]: http://www.gnu.org/copyleft/gpl.html +[MIT License]: http://www.opensource.org/licenses/mit-license.php diff --git a/tests2/formatter.py b/tests2/formatter.py new file mode 100644 index 0000000..26d850f --- /dev/null +++ b/tests2/formatter.py @@ -0,0 +1,55 @@ +from __future__ import with_statement +import os + +excl_tm_cases = """basic_safe_mode +basic_safe_mode_escape +auto_link_safe_mode +code_safe_emphasis +emacs_head_vars +emacs_tail_vars +footnotes +footnotes_letters +footnotes_markup +footnotes_safe_mode_escape +nested_list_safe_mode +issue2_safe_mode_borks_markup +issue3_bad_code_color_hack +link_defn_spaces_in_url +link_patterns +link_patterns_double_hit +link_patterns_edge_cases +mismatched_footnotes +nested_lists_safe_mode +pyshell +syntax_color""" + + +def reformat(path, dest, ex=""): + excl = ex.split("\n") + for fname in os.listdir(path): + if fname.endswith(".html"): + if fname[:-5] in excl: + continue + res = processFile(path + fname) + with open(dest + fname, "w") as rfile: + rfile.write(res) + +def processFile(filePath): + with open(filePath) as f: + result = f.read() + result = result.replace("\n\n

", "

") + result = result.replace("\n<", "<") + result = result.replace("", "\n") + result = result.replace("

  • ", "
  • \n") + result = result.replace(">\n

    ", ">

    ") + result = result.replace("\" />", "\"/>") + result = result.replace("

    \n", "\n

    \n") + + return result + +if __name__ == "__main__": + reformat("php-markdown-cases/", "php-markdown-cases-new/") + reformat("tm-cases/", "tm-cases-new/", excl_tm_cases) + + + \ No newline at end of file -- cgit v1.2.3