generate titles for course desc.
This commit is contained in:
parent
10408e5fa3
commit
b3bc916746
2 changed files with 93 additions and 5 deletions
|
@ -23,7 +23,7 @@ class MarkdownGenerator:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def generate_markdown(self,ti,pagebreak = False,title = None) -> str:
|
def generate_markdown(self,ti,pagebreak = False,title = False) -> str:
|
||||||
|
|
||||||
line_length = 128
|
line_length = 128
|
||||||
column_ratio= 0.28
|
column_ratio= 0.28
|
||||||
|
@ -32,7 +32,7 @@ class MarkdownGenerator:
|
||||||
d_len = line_length-h_len
|
d_len = line_length-h_len
|
||||||
|
|
||||||
if title:
|
if title:
|
||||||
print('#',title,'\n')
|
print('#',ti[0][1],'\n')
|
||||||
|
|
||||||
print(''.join(['+',"".ljust(h_len,'-'),'+',"".ljust(d_len,'-'),'+']))
|
print(''.join(['+',"".ljust(h_len,'-'),'+',"".ljust(d_len,'-'),'+']))
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class CourseBuilder:
|
||||||
return [k,', '.join(parts)]
|
return [k,', '.join(parts)]
|
||||||
|
|
||||||
|
|
||||||
def process(self,meta,fields = [],lang = 'de',pagebreak = False):
|
def process(self,meta,fields = [],lang = 'de',pagebreak = False,createTitle=False):
|
||||||
|
|
||||||
table_items = []
|
table_items = []
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ class CourseBuilder:
|
||||||
case 'multikey': table_items.append(self.process_multikey(meta,field,lang))
|
case 'multikey': table_items.append(self.process_multikey(meta,field,lang))
|
||||||
|
|
||||||
mdg = MarkdownGenerator()
|
mdg = MarkdownGenerator()
|
||||||
mdg.generate_markdown(table_items,pagebreak)
|
mdg.generate_markdown(table_items,pagebreak,createTitle)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -161,6 +161,7 @@ def main():
|
||||||
parser.add_argument('-f','--fields',help="Fields to be used, the table will be build accordingly",action="extend", nargs="+", type=str)
|
parser.add_argument('-f','--fields',help="Fields to be used, the table will be build accordingly",action="extend", nargs="+", type=str)
|
||||||
parser.add_argument('-s','--schema',help="using provided schema")
|
parser.add_argument('-s','--schema',help="using provided schema")
|
||||||
parser.add_argument('-p','--pagebreak',action="store_true",help="add a pagebreak after each module")
|
parser.add_argument('-p','--pagebreak',action="store_true",help="add a pagebreak after each module")
|
||||||
|
parser.add_argument('-t','--title',action="store_true",help="take first value in list as title")
|
||||||
|
|
||||||
# get arguments
|
# get arguments
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -184,7 +185,7 @@ def main():
|
||||||
|
|
||||||
for m in args.meta:
|
for m in args.meta:
|
||||||
with open(m) as fm:
|
with open(m) as fm:
|
||||||
cb.process(yaml.load(fm,Loader=yaml.Loader),fields=actual_fields,lang=args.lang,pagebreak=args.pagebreak)
|
cb.process(yaml.load(fm,Loader=yaml.Loader),fields=actual_fields,lang=args.lang,pagebreak=args.pagebreak,createTitle=args.title)
|
||||||
else:
|
else:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,19 @@ name:
|
||||||
#
|
#
|
||||||
|
|
||||||
content:
|
content:
|
||||||
|
en: |
|
||||||
|
1. Dog
|
||||||
|
1. German Shepherd
|
||||||
|
2. Belgian Shepherd
|
||||||
|
1. Malinois
|
||||||
|
2. Groenendael
|
||||||
|
4. Tervuren
|
||||||
|
2. Cat
|
||||||
|
1. Siberian
|
||||||
|
2. Siamese
|
||||||
|
|
||||||
|
|
||||||
|
content-alt:
|
||||||
en: |
|
en: |
|
||||||
1. Dog
|
1. Dog
|
||||||
|
|
||||||
|
@ -31,3 +44,77 @@ content:
|
||||||
|
|
||||||
2. Siamese
|
2. Siamese
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
content-blah:
|
||||||
|
en: |
|
||||||
|
1. Blah
|
||||||
|
|
||||||
|
2. Blub
|
||||||
|
|
||||||
|
1. Blah
|
||||||
|
|
||||||
|
1. Blub
|
||||||
|
|
||||||
|
1. Blah
|
||||||
|
|
||||||
|
1. Blub
|
||||||
|
|
||||||
|
1. Blah
|
||||||
|
|
||||||
|
1. Blub
|
||||||
|
|
||||||
|
1. Blah
|
||||||
|
|
||||||
|
1. Blub
|
||||||
|
|
||||||
|
3. Blah
|
||||||
|
|
||||||
|
4. Blub
|
||||||
|
|
||||||
|
5. Blah
|
||||||
|
|
||||||
|
6. Blah and Blub
|
||||||
|
|
||||||
|
1. Blah
|
||||||
|
|
||||||
|
1. Blub
|
||||||
|
|
||||||
|
7. Blah and Blub
|
||||||
|
|
||||||
|
- Blah
|
||||||
|
|
||||||
|
- Blub
|
||||||
|
|
||||||
|
- Blah
|
||||||
|
|
||||||
|
- Blub
|
||||||
|
|
||||||
|
8. Blub and Blah
|
||||||
|
|
||||||
|
- Blah
|
||||||
|
|
||||||
|
- Blub
|
||||||
|
|
||||||
|
- Blah
|
||||||
|
|
||||||
|
- Blub
|
||||||
|
|
||||||
|
- Blah
|
||||||
|
|
||||||
|
- Blub
|
||||||
|
|
||||||
|
- Blah
|
||||||
|
|
||||||
|
- Blub
|
||||||
|
|
||||||
|
9. Blah, Blub and Blub
|
||||||
|
|
||||||
|
- Blah
|
||||||
|
|
||||||
|
- Blub
|
||||||
|
|
||||||
|
- Blah
|
||||||
|
|
||||||
|
- Blub
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue