improve title parsing, must match either the amount of bytes or have only - or … | |
git clone git://git.codemadness.org/smu | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit d19644d2392f4db2d0caccfebef6147ac9b8bae2 | |
parent 469673436b2708e885b9e95f0f792a7ffe10ac86 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Thu, 13 May 2021 17:04:10 +0200 | |
improve title parsing, must match either the amount of bytes or have only - or … | |
This also fixes an identical case with a ruler "---\n". | |
Diffstat: | |
M smu.c | 2 +- | |
M testdoc | 18 ++++++++++++++++++ | |
2 files changed, 19 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/smu.c b/smu.c | |
@@ -607,7 +607,7 @@ dounderline(const char *begin, const char *end, int newbloc… | |
for (i = 0; i < LENGTH(underline); i++) { | |
for (j = 0; p + j != end && p[j] != '\n' && p[j] == underline[… | |
; | |
- if (j > 0) { | |
+ if (j == l || (p[j] == '\n' && j > 3)) { | |
fputs(underline[i].before, stdout); | |
if (underline[i].process) | |
process(begin, begin + l, 0); | |
diff --git a/testdoc b/testdoc | |
@@ -132,3 +132,21 @@ h2 no need to match exactly | |
this one is not a title | |
- | |
+ | |
+## title | |
+- a | |
+ | |
+## title | |
+-- a | |
+ | |
+## title | |
+-- | |
+ | |
+a | |
+- | |
+ | |
+aa | |
+-- | |
+ | |
+abc | |
+--- |