From 021a0f69d39f6c8de846a1d7569459a1e89cabcb Mon Sep 17 00:00:00 2001 From: Hartmut Seichter Date: Sun, 19 Nov 2023 23:17:44 +0100 Subject: [PATCH] prototyping table generator --- TODO.md | 1 + coursebuilder/tablegenerator.py | 35 ++++++++++++++++++++++++++++++++- test/simple/book.yaml | 5 +++++ test/simple/mod.cg.yaml | 2 ++ test/simple/mod.test.yaml | 2 +- 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index c073484..484edcc 100644 --- a/TODO.md +++ b/TODO.md @@ -4,3 +4,4 @@ * [ ] custom python code in tables * [x] fix overlong table cells (pandoc longtable only deals with overlong tables but not cells) * [ ] add a book mode for mixing input and headers (# Blah -m mod.cg.yaml) +* [ ] table generator diff --git a/coursebuilder/tablegenerator.py b/coursebuilder/tablegenerator.py index 806d29b..e86d81b 100644 --- a/coursebuilder/tablegenerator.py +++ b/coursebuilder/tablegenerator.py @@ -1,5 +1,6 @@ import token +import string class TableGenerator: def __init__(self) -> None: @@ -34,4 +35,36 @@ class TableGenerator: row.append(' ') print(' | '.join(row)) - \ No newline at end of file + + self.run_template() + + + def run_template(self): + t = string.Template(self.get_latex_template()) + print(t.substitute({ 'value' : "Test"})) + + + + def get_latex_template(self) -> str: + + return (r'\documentclass{article}' + r'\usepackage[utf8]{inputenc}' + r'\usepackage[]{tabularx}' + r'\usepackage[margin=0.7in]{geometry}' + r'\begin{document}' + r'\begin{table}[ht]' + r'\begin{tabular}{l c c}' + r'${value}' + r'\end{tabular}' + r'\end{table}' + r'\end{document}') + + +# +# Kompetenz & Kennen & Wertung \\ + +# 1 & Pandoc & +++ \\ +# 2 & Latex & ++ \\ +# 3 & Writer & +- \\ +# +# latex image.tex;dvisvgm image.dvi \ No newline at end of file diff --git a/test/simple/book.yaml b/test/simple/book.yaml index 3243fdb..6cd1b46 100644 --- a/test/simple/book.yaml +++ b/test/simple/book.yaml @@ -1,3 +1,8 @@ + +# +# demonstrates a coursebook setting +# + book: - fields: - name diff --git a/test/simple/mod.cg.yaml b/test/simple/mod.cg.yaml index f23c36f..6a1e04b 100644 --- a/test/simple/mod.cg.yaml +++ b/test/simple/mod.cg.yaml @@ -34,6 +34,8 @@ goal: bewerten. Sie lernen grundsätzliche Technologien der 3D Echtzeitdarstellung kennen und wenden diese an. + + en: | Computer graphics is describing all techniques in computer science generating images perceivable by humans. Participants will have a broad diff --git a/test/simple/mod.test.yaml b/test/simple/mod.test.yaml index 901553e..d600dda 100644 --- a/test/simple/mod.test.yaml +++ b/test/simple/mod.test.yaml @@ -4,7 +4,7 @@ name: test: - + competency-table: de: - "Lineare Algebra": 'ABC'