Commit 35c05690b8b09fd056ad82410a5d1e8f789dce0a

Thomas de Grivel 2024-09-05T02:52:55

fix Markdown.titles

diff --git a/.gitignore b/.gitignore
index e25d591..b459bfc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -88,6 +88,10 @@ test/libkc3_test
 test/libkc3_test_asan
 test/libkc3_test_cov
 test/libkc3_test_debug
+test/markdown/*.diff
+test/markdown/*.err
+test/markdown/*.out
+test/markdown/*.ret
 *.tmp
 ucd2c/ucd2c
 win32/kc3*
diff --git a/markdown/markdown.c b/markdown/markdown.c
index cb12e5f..162b886 100644
--- a/markdown/markdown.c
+++ b/markdown/markdown.c
@@ -10,8 +10,8 @@
  * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
  * THIS SOFTWARE.
  */
-#include <md4c.h>
-#include <md4c-html.h>
+#include "md4c.h"
+#include "md4c-html.h"
 #include <libkc3/kc3.h>
 #include "markdown.h"
 
@@ -172,7 +172,7 @@ s32 markdown_titles_leave_block (MD_BLOCKTYPE type, void *detail,
     str_list = NULL;
     str_list_tail = &str_list;
     i = 0;
-    while (i < level) {
+    while (i <= level) {
       *str_list_tail = list_new_str_cast(&sym_Str, tuple_count + i,
                                          NULL);
       str_list_tail = &(*str_list_tail)->next.data.list;
@@ -180,7 +180,6 @@ s32 markdown_titles_leave_block (MD_BLOCKTYPE type, void *detail,
       str_list_tail = &(*str_list_tail)->next.data.list;
       i++;
     }
-    // i = level
     while (i < 6) {
       tag_init_u8(tuple_count + i, 0);
       i++;
diff --git a/test/markdown/titles.diff b/test/markdown/titles.diff
deleted file mode 100644
index c62a856..0000000
--- a/test/markdown/titles.diff
+++ /dev/null
@@ -1,14 +0,0 @@
---- titles.out.expected	Wed Sep  4 18:56:57 2024
-+++ titles.out	Thu Sep  5 01:54:45 2024
-@@ -1,4 +1,2 @@
--quote Markdown.titles("Text.\n")
--[]
--quote Markdown.titles("# Title\nText.\n\n## Title 2\n")
--["h1-1", "h2-1.1"]
-+Markdown.titles("Text.\n")
-+Segmentation fault (core dumped) 
---- titles.ret.expected	Wed Sep  4 18:57:08 2024
-+++ titles.ret	Thu Sep  5 01:54:45 2024
-@@ -1 +1 @@
--0
-+139
diff --git a/test/markdown/titles.out b/test/markdown/titles.out
deleted file mode 100644
index ebd449a..0000000
--- a/test/markdown/titles.out
+++ /dev/null
@@ -1,2 +0,0 @@
-Markdown.titles("Text.\n")
-Segmentation fault (core dumped) 
diff --git a/test/markdown/titles.out.expected b/test/markdown/titles.out.expected
index 87a5ae0..1b1995e 100644
--- a/test/markdown/titles.out.expected
+++ b/test/markdown/titles.out.expected
@@ -1,4 +1,4 @@
 Markdown.titles("Text.\n")
 []
 Markdown.titles("# Title\nText.\n\n## Title 2\n")
-["h1-1", "h2-1.1"]
+["1. Title", "1.1. Title 2"]
diff --git a/test/markdown/titles.ret b/test/markdown/titles.ret
deleted file mode 100644
index 897bdc8..0000000
--- a/test/markdown/titles.ret
+++ /dev/null
@@ -1 +0,0 @@
-139