diff --git a/grawlix.py b/grawlix.py index 7187b9c..b117282 100644 --- a/grawlix.py +++ b/grawlix.py @@ -2,14 +2,15 @@ from collections import defaultdict import random import yaml +import chevron class GrawlixCodex(): - def __init__(self, width=100, height=10, wordcount=50000): + def __init__(self, width=30, height=10, wordcount=50000): self.width = width self.height = height self.smallest = 1 - self.longest = 8 + self.longest = 6 self.wordcount = wordcount @@ -41,20 +42,33 @@ class GrawlixCodex(): l = random.randint(self.smallest, self.longest) for g in range(l): yield random.choice(list(self.groups["glyph"])) + if random.randint(1, 10) > 8: + yield random.choice(list(self.groups["colour"])) yield(self.blank) - + def write(self): row = [] for g in self.text(): row.append(g) if len(row) == self.width: - glyphs = [ f' ' for g in row ] + glyphs = [ f' ' for g in row ] print(''.join(glyphs)) print('
') row = [] -gc = GrawlixCodex() +gc = GrawlixCodex(wordcount=500) gc.config("./config.yml") gc.load_emojos() -gc.write() + +content = { + "front_matter": "Title page", + "chapters": [ + { "title": "One", "text": "blah blah" }, + { "title": "Two", "text": "foo foo" }, + ] +} + + +with open("template.html", "r") as tf: + print(chevron.render(tf, content)) diff --git a/output.html b/output.html new file mode 100644 index 0000000..67cf50a --- /dev/null +++ b/output.html @@ -0,0 +1,156 @@ +                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
+                               +
diff --git a/pyproject.toml b/pyproject.toml index 43b3316..282b5e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,8 +5,6 @@ description = "Add your description here" readme = "README.md" requires-python = ">=3.9" dependencies = [ - "grawlix>=0.1.0", + "chevron>=0.14.0", + "pyyaml>=6.0.3", ] - -[tool.uv.sources] -grawlix = { git = "https://git.tilde.town/bombinans/grawlix.git" } diff --git a/template.html b/template.html new file mode 100644 index 0000000..c47e060 --- /dev/null +++ b/template.html @@ -0,0 +1,20 @@ + + + Grawlix Codex + + + +
+ {{front_matter}} +
+ +
+ {{#chapters}} +
+
{{title}}
+
{{text}}
+
+ {{/chapters}} +
+ +