/jam

Markdown -> HTML SiteGenerator.

Primary LanguagePythonMIT LicenseMIT

πŸ“ 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

customize main.py line: 9

title = " (HTML Pages Name) "

customize base.html

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>

make markdownFile

content/ ~ .md

(date)
---
(title)
---
・・・




---

run main.py

$ python3 main.py
~ .md  >>>  Creating ~ .html

(2) generate Index Pages.

remove comment out main.py line:20 ~ 29 and 57 ~ 75

# γƒ–γƒ­γ‚°ζ©Ÿθƒ½γ‚’θΏ½εŠ γ—γΎγ—γŸοΌ δ½Ώη”¨γ™γ‚‹ε ΄εˆγ―γ‚³γƒ‘γƒ³γƒˆγ‚’ε€–γ—γ¦γγ γ•γ„οΌ

# 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