forked from PaddlePaddle/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is a pull-request to revise the release notes, test=develop (Pad…
- Loading branch information
1 parent
b555cf4
commit c27f4b5
Showing
5 changed files
with
681 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
- repo: https://github.com/pre-commit/mirrors-yapf.git | ||
sha: v0.16.0 | ||
hooks: | ||
- id: yapf | ||
files: \.py$ | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
sha: a11d9314b22d8f8c7556443875b731ef05965464 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: detect-private-key | ||
files: (?!.*paddle)^.*$ | ||
- id: end-of-file-fixer | ||
files: \.md$ | ||
- id: trailing-whitespace | ||
files: \.md$ | ||
- repo: https://github.com/Lucas-C/pre-commit-hooks | ||
sha: v1.0.1 | ||
hooks: | ||
- id: forbid-crlf | ||
files: \.md$ | ||
- id: remove-crlf | ||
files: \.md$ | ||
- id: forbid-tabs | ||
files: \.md$ | ||
- id: remove-tabs | ||
files: \.md$ | ||
- repo: https://github.com/reyoung/pre-commit-hooks-jinja-compile.git | ||
sha: 4a369cc72a4a2b8d3813ab8cc17abb5f5b21ef6c | ||
hooks: | ||
- id: convert-jinja2-into-html | ||
# The argument means repleace filename from pattern `.*/([^/]*)\.tmpl` to `\1` | ||
args: ['--filename_pattern=.*/([^/]*)\.tmpl', '--filename_repl=\1'] | ||
- repo: local | ||
hooks: | ||
- id: convert-markdown-into-html | ||
name: convert-markdown-into-html | ||
description: Convert README.md into index.html and README.cn.md into index.cn.html | ||
entry: python .pre-commit-hooks/convert_markdown_into_html.py | ||
language: system | ||
files: .+README(\.cn)?\.md$ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import argparse | ||
import re | ||
import sys | ||
|
||
HEAD = """ | ||
<html> | ||
<head> | ||
<script type="text/x-mathjax-config"> | ||
MathJax.Hub.Config({ | ||
extensions: ["tex2jax.js", "TeX/AMSsymbols.js", "TeX/AMSmath.js"], | ||
jax: ["input/TeX", "output/HTML-CSS"], | ||
tex2jax: { | ||
inlineMath: [ ['$','$'] ], | ||
displayMath: [ ['$$','$$'] ], | ||
processEscapes: true | ||
}, | ||
"HTML-CSS": { availableFonts: ["TeX"] } | ||
}); | ||
</script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js" async></script> | ||
<script type="text/javascript" src="../.tools/theme/marked.js"> | ||
</script> | ||
<link href="http://cdn.bootcss.com/highlight.js/9.9.0/styles/darcula.min.css" rel="stylesheet"> | ||
<script src="http://cdn.bootcss.com/highlight.js/9.9.0/highlight.min.js"></script> | ||
<link href="http://cdn.bootcss.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"> | ||
<link href="https://cdn.jsdelivr.net/perfect-scrollbar/0.6.14/css/perfect-scrollbar.min.css" rel="stylesheet"> | ||
<link href="../.tools/theme/github-markdown.css" rel='stylesheet'> | ||
</head> | ||
<style type="text/css" > | ||
.markdown-body { | ||
box-sizing: border-box; | ||
min-width: 200px; | ||
max-width: 980px; | ||
margin: 0 auto; | ||
padding: 45px; | ||
} | ||
</style> | ||
<body> | ||
<div id="context" class="container-fluid markdown-body"> | ||
</div> | ||
<!-- This block will be replaced by each markdown file content. Please do not change lines below.--> | ||
<div id="markdown" style='display:none'> | ||
""" | ||
|
||
TAIL = """ | ||
</div> | ||
<!-- You can change the lines below now. --> | ||
<script type="text/javascript"> | ||
marked.setOptions({ | ||
renderer: new marked.Renderer(), | ||
gfm: true, | ||
breaks: false, | ||
smartypants: true, | ||
highlight: function(code, lang) { | ||
code = code.replace(/&/g, "&") | ||
code = code.replace(/>/g, ">") | ||
code = code.replace(/</g, "<") | ||
code = code.replace(/ /g, " ") | ||
return hljs.highlightAuto(code, [lang]).value; | ||
} | ||
}); | ||
document.getElementById("context").innerHTML = marked( | ||
document.getElementById("markdown").innerHTML) | ||
</script> | ||
</body> | ||
""" | ||
|
||
|
||
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", | ||
encoding="utf-8") as output: | ||
output.write(HEAD) | ||
with open(filename, encoding="utf-8") as input: | ||
for line in input: | ||
output.write(line) | ||
output.write(TAIL) | ||
|
||
return retv | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(convert_markdown_into_html()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
for file in $@ ; do | ||
markdown-to-ipynb < $file > ${file%.*}".ipynb" | ||
if [ $? -ne 0 ]; then | ||
echo >&2 "markdown-to-ipynb $file error" | ||
exit 1 | ||
fi | ||
done | ||
|
Oops, something went wrong.