π jam
markdown -> HTML PageGenerator.
How to use
- clone jam
- install
markdown
$ git clone https://github.com/gamma-410/jam.git
$ cd jam
$ pip install markdown
(1) generate HTML
main.py
line: 9
customize title = " (HTML Pages Name) "
base.html
customize assets/base.html
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8"><meta name="robots" content="noindex,nofollow">
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<title>{}</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
{}
</body>
<html>
markdownFile
make content/ ~ .md
(date)
---
(title)
---
γ»γ»γ»
---
main.py
run $ python3 main.py
~ .md >>> Creating ~ .html
(2) generate Index Pages.
main.py
line:20 ~ 29
and 57 ~ 75
remove comment out # γγγ°ζ©θ½γθΏ½ε γγΎγγοΌ δ½Ώη¨γγε ΄εγ―γ³γ‘γ³γγε€γγ¦γγ γγοΌ
# mdγγΌγΏγζΊε
indexMdOpen = open('assets/index.md', encoding='utf-8')
s = indexMdOpen.read()
name1 = os.path.splitext(os.path.basename(htmlName))[0]
s = '- [' + name1 + ' - ' + date + ']' + '(' + name1 + '.html) \n' + s
indexMdOpen = open('assets/index.md', 'w', encoding='utf-8')
indexMdOpen.write(s)
indexMdOpen.close()
# γγγ°ζ©θ½γθΏ½ε γγΎγγοΌ δ½Ώη¨γγε ΄εγ―γ³γ‘γ³γγε€γγ¦γγ γγοΌ
mdOpen = open('assets/index.md', 'r', encoding="utf-8")
mdData = mdOpen.read()
md = markdown.Markdown() # Create an instance?
formatMdData = md.convert(mdData) # To convert md to html, use md.convert.
html = open('assets/base.html', 'r', encoding="utf-8") # Define the HTML template.
htmlData = html.read()
formatData = htmlData.format(title, formatMdData) # Put the title and formatted md into the template.
# 葨瀺ε¦η
name = os.path.splitext(os.path.basename(htmlName))[0]
print("jam: ", "index.md", " >>> ", "Creating", "index.html")
htmlFileName = 'index.html'
writeHTMLFile = open("generate/"+htmlFileName, 'w', encoding="utf-8")
writeHTMLFile.write(formatData)
writeHTMLFile.close()
license
MIT