提交 58a33469 编写于 作者: Y Yu Yang 提交者: GitHub

Merge pull request #92 from wangkuiyi/converter

Merge template.html and build.sh into convert-markdown-into-html.sh
#!/bin/bash
function find_line() {
local fn=$1
local x=0
cat $fn | while read line; do
local x=$(( x+1 ))
if echo $line | grep '${MARKDOWN}' -q; then
echo $x
break
fi
done
}
MD_FILE=$1
TMPL_FILE=$2
TPL_LINE=`find_line $TMPL_FILE`
cat $TMPL_FILE | head -n $((TPL_LINE-1))
cat $MD_FILE
cat $TMPL_FILE | tail -n +$((TPL_LINE+1))
markdown_file=$1
# Notice: the single-quotes around EOF below make outputs
# verbatium. c.f. http://stackoverflow.com/a/9870274/724872
cat <<'EOF'
<html>
<head>
<script type="text/x-mathjax-config">
......@@ -11,15 +16,15 @@
},
"HTML-CSS": { availableFonts: ["TeX"] }
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js" async></script>
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js" async></script>
<script type="text/javascript" src="../.tmpl/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>
<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="../.tmpl/github-markdown.css" rel='stylesheet'>
<link href="../.tmpl/github-markdown.css" rel='stylesheet'>
</head>
<style type="text/css" >
.markdown-body {
......@@ -39,7 +44,11 @@
<!-- This block will be replaced by each markdown file content. Please do not change lines below.-->
<div id="markdown" style='display:none'>
${MARKDOWN}
EOF
cat $markdown_file
cat <<'EOF'
</div>
<!-- You can change the lines below now. -->
......@@ -61,3 +70,4 @@ document.getElementById("context").innerHTML = marked(
document.getElementById("markdown").innerHTML)
</script>
</body>
EOF
......@@ -2,5 +2,5 @@
for file in `find . -name '*.md' | grep -v '^./README.md'`
do
bash .tmpl/build.sh $file .tmpl/template.html > `dirname $file`/index.html
bash .tmpl/convert-markdown-into-html.sh $file > `dirname $file`/index.html
done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册