Package: tanuky
tanuky: simple & flexible SSGDescriptionThis is a simple SSG (Static Site Generator) written in Python.Unlike other common SSGs, this tool provides only minimal functionality.It generates a site based on a template and markdown, that's all.Therefore, all the possibilities of the site that can be created are left to the designer.InstallationFrom pypi (recommended):pip install tanukyIf you want the latest commit:pip install git+https://github.com/laddge/tanukyFrom source:git clone https://github.com/laddge/tanuky ./tanuky
cd tanuky
python setup.py installUsageFile placement.
├── dist # distdir
├── src # srcdir
│   ├── css
│   │   └── style.css
│   ├── images
│   │   └── dog.jpeg
│   ├── js
│   │   └── main.js
│   ├── pages
│   │   └── example.md
│   ├── .build
│   │   └── hoge.txt
│   └── index.html
├── templates # tpldir
│   └── hoge.html
└── generate.pydistdir (default: ./dist)Generated files are placed here.Overwritten each times.srcdir (default: ./src)Put source files here.tpldir (default: ./templates)Put templates here.Template files must be named{template_name}.html.After generated:./dist # distdir
├── css
│   └── style.css
├── images
│   └── dog.jpeg
├── js
│   └── main.js
├── pages
│   └── example.html
└── index.htmlLike this, Markdown is converted to HTML and other files are copied exactly as they are.Dotted files and dirs are NOT copied.How to write Markdownex:---
Template: hoge
Title: Hoge Fuga
Desc: test page
---

# Test page
hoge...Front matterWrite page config between "---" in Yaml.Its value passed to the template.Template nameTemplate name must be defined in Front matter.And, respective template file must be in tpldir.Markdown sentencesMarkdown sentences are convert to HTML and passed to template as "Body".How to write templatesex:<!DOCTYPE html>
<html>
    <head>
        <meta name="description" content="{{ Desc }}">
        <title>{{ Title }}</title>
    </head>
    <body>
        {{ Body }}
    </body>
</html>Tanuky uses template engineJinja2.Variables defined in Front matter can be used in template.{{ Body }}shows contents which is converted from Markdown.Generator script# generate.py
import tanuky

tnk = tanuky.Tanuky()
tnk.generate()The generator works with just this script.tnk = tanuky.Tanuky()Define the generator object.You can specify srcdir, tpldir, distdir like this:tnk = tanuky.Tanuky(srcdir="./src", tpldir="./templates", distdir="./dist")tnk.generate()Start generate process.AdvancedInclude other templatesex:templates/header.html<header>
    <a href="/">{{ Title }}</a>
</header>templates/page.html<!DOCTYPE html>
<html>
    <head>
        <meta name="description" content="{{ Desc }}">
        <title>{{ Title }}</title>
    </head>
    <body>
        {% include "header.html" %}
        {{ Body }}
    </body>
</html>You can include other templates using{% include "{template_name}.html" %}.Define globalsex:# generate.py
import tanuky

tnk = tanuky.Tanuky()


def func(arg):
    return f"Arg: {arg}"


hoge = "test var"
tnk.globals.update(func=func)
tnk.globals.update(hoge=hoge)
tnk.generate()You can define global variables or functions usingtnk.globals.update().They are refered in templates like variables defined in Front matter, and they have lower priority than Front matter.Custom Markdown converterBy default, tanuky usesPython-Markdownas Markdown converter.If you want to use another converter, use this:# generate.py
import tanuky


class MyTanuky(tanuky.Tanuky):
    def mkhtml(self, mdbody):
        # convert mdbody to html
        return html


tnk = MyTanuky()
tnk.generate()ExampleAn example is available onladdge/tanuky-example.Release Notev1.3.1(2022/03/31)Fix Markdown parserv1.3.0(2022/03/30)Remove handler featurev1.2.3(2022/03/29)Fix url of MdDoc objectv1.2.2(2022/03/29)Fix errorv1.2.1(2022/03/29)Provide Markdown listv1.2.0(2022/03/29)Add handlerv1.1.0(2022/03/28)Use Jinja2 environmentThis update allows you to use all the features of Jinja2v1.0.3(2022/03/28)Move example tree to another repov1.0.2(2022/03/25)Add example treev1.0.1(2022/03/24)Fix install bugv1.0.0(2022/03/24)First releaseLicenseThis project is under the MIT-License.See alsoLICENSE.AuthorLaddge