From 10408e5fa3ccf0b533128ba1c73b58c8f7510975 Mon Sep 17 00:00:00 2001 From: Hartmut Seichter Date: Thu, 9 Nov 2023 20:14:56 +0100 Subject: [PATCH] added test course to fix corner cases like nested numbered lists --- coursebuilder/__main__.py | 3 ++- test.md | 10 ++++++++++ test/simple/mod.test.yaml | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 test.md create mode 100644 test/simple/mod.test.yaml diff --git a/coursebuilder/__main__.py b/coursebuilder/__main__.py index 68e96f2..e91f791 100644 --- a/coursebuilder/__main__.py +++ b/coursebuilder/__main__.py @@ -49,11 +49,12 @@ class MarkdownGenerator: # row head h = textwrap.wrap(k, h_len, break_long_words=False) - wrapper = textwrap.TextWrapper(d_len) + wrapper = textwrap.TextWrapper(d_len,break_long_words=True,replace_whitespace=False) # split test to wrap lines into correct length t = [wrapper.wrap(line) for line in v.split('\n')] + # replace empty arrays from split with a empty string t = list(map(lambda e: [""] if e == [] else e, t)) diff --git a/test.md b/test.md new file mode 100644 index 0000000..4f6bb50 --- /dev/null +++ b/test.md @@ -0,0 +1,10 @@ +---------------------------------------------------------------------------------------------------------------------------------- +Inhalt Test +------------------------------------ --------------------------------------------------------------------------------------------- +Modulinhalte 1. Section One + 2. Section Two + 1. Section Two Sub One + 2. Section Two Sub Two + 3. Section Two Sub Three + 4. Section Two Sub Four +---------------------------------------------------------------------------------------------------------------------------------- diff --git a/test/simple/mod.test.yaml b/test/simple/mod.test.yaml new file mode 100644 index 0000000..e5bb6f7 --- /dev/null +++ b/test/simple/mod.test.yaml @@ -0,0 +1,33 @@ + +name: + en: Test Course + + +# +# nested lists seem to work in Markdown only in the US style way +# +# reference here: https://meta.stackexchange.com/questions/85474/how-to-write-nested-numbered-lists +# +# note the parser actually corrects 'Tervuren' to 3 in resulting data +# + +content: + en: | + 1. Dog + + 1. German Shepherd + + 2. Belgian Shepherd + + 1. Malinois + + 2. Groenendael + + 4. Tervuren + + 2. Cat + + 1. Siberian + + 2. Siamese +