From 01339b6f6e7fef00d8c57125391723cb757d0eec Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 7 Mar 2017 16:00:10 -0800 Subject: [PATCH] Add pre-commit-hooks/convert-markdown-into-html.py and use it --- .gitignore | 2 + .pre-commit-config.yaml | 8 + fit_a_line/README.en.md | 2 +- fit_a_line/index.en.html | 208 +++---- fit_a_line/index.html | 147 ++--- gan/index.html | 6 +- image_caption/index.html | 6 +- image_classification/index.en.html | 6 +- image_classification/index.html | 6 +- image_detection/index.html | 6 +- image_qa/index.html | 6 +- index.html | 74 ++- label_semantic_roles/index.en.html | 46 +- label_semantic_roles/index.html | 6 +- machine_translation/index.en.html | 6 +- machine_translation/index.html | 512 ++++++------------ pre-commit-hooks/build.sh | 9 - ...-html.sh => convert_markdown_into_html.py} | 44 +- query_relationship/index.html | 6 +- recognize_digits/index.en.html | 6 +- recognize_digits/index.html | 6 +- recommender_system/index.en.html | 6 +- recommender_system/index.html | 462 +++++++++------- skip_thought/index.html | 6 +- speech_recognition/index.html | 6 +- understand_sentiment/index.en.html | 6 +- understand_sentiment/index.html | 6 +- word2vec/index.en.html | 6 +- word2vec/index.html | 209 ++++--- 29 files changed, 899 insertions(+), 926 deletions(-) delete mode 100755 pre-commit-hooks/build.sh rename pre-commit-hooks/{convert-markdown-into-html.sh => convert_markdown_into_html.py} (70%) mode change 100755 => 100644 diff --git a/.gitignore b/.gitignore index 0a0dd02..b7dfec3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +deprecated +*~ pandoc.template .DS_Store \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0d8234b..cba2de8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,3 +14,11 @@ - id: check-symlinks - id: detect-private-key - id: end-of-file-fixer +- repo: local + hooks: + - id: convert-markdown-into-html + name: convert-markdown-into-html + description: "Convert README.md into index.html and README.en.md into index.en.html" + entry: python pre-commit-hooks/convert_markdown_into_html.py + language: system + files: \.md$ diff --git a/fit_a_line/README.en.md b/fit_a_line/README.en.md index 21f457c..29aabda 100644 --- a/fit_a_line/README.en.md +++ b/fit_a_line/README.en.md @@ -202,4 +202,4 @@ This chapter introduces *Linear Regression* and how to train and test this model 4. Bishop C M. Pattern recognition[J]. Machine Learning, 2006, 128.
-知识共享许可协议
本教程PaddlePaddle 创作,采用 知识共享 署名-非商业性使用-相同方式共享 4.0 国际 许可协议进行许可。 +Common Creative License This tutorial was created and published with [Creative Common License 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/). diff --git a/fit_a_line/index.en.html b/fit_a_line/index.en.html index b2492b2..8e3a35f 100644 --- a/fit_a_line/index.en.html +++ b/fit_a_line/index.en.html @@ -1,3 +1,4 @@ + + + + + + + + + + + - Please access github home page + +
+
+ + + + + + diff --git a/label_semantic_roles/index.en.html b/label_semantic_roles/index.en.html index a3fc663..84c2273 100644 --- a/label_semantic_roles/index.en.html +++ b/label_semantic_roles/index.en.html @@ -1,3 +1,4 @@ + -EOF +""" + + +def convert_markdown_into_html(argv=None): + parser = argparse.ArgumentParser() + parser.add_argument('filenames', nargs='*', help='Filenames to fix') + args = parser.parse_args(argv) + + retv = 0 + + for filename in args.filenames: + with open( + re.sub(r"README", "index", re.sub(r"\.md$", ".html", filename)), + "w") as output: + output.write(HEAD) + with open(filename) as input: + for line in input: + output.write(line) + output.write(TAIL) + + return retv + + +if __name__ == '__main__': + sys.exit(convert_markdown_into_html()) diff --git a/query_relationship/index.html b/query_relationship/index.html index bd5f85a..de7844e 100644 --- a/query_relationship/index.html +++ b/query_relationship/index.html @@ -1,3 +1,4 @@ +