improve title parsing, must match either the amount of bytes or have only - or = on a line - smu - smu - simple markup (Markdown) processor (fork, fixes + features)
(HTM) git clone git://git.codemadness.org/smu
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit d19644d2392f4db2d0caccfebef6147ac9b8bae2
(DIR) parent 469673436b2708e885b9e95f0f792a7ffe10ac86
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Thu, 13 May 2021 17:04:10 +0200
improve title parsing, must match either the amount of bytes or have only - or = on a line
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(-)
---
(DIR) diff --git a/smu.c b/smu.c
@@ -607,7 +607,7 @@ dounderline(const char *begin, const char *end, int newblock)
for (i = 0; i < LENGTH(underline); i++) {
for (j = 0; p + j != end && p[j] != '\n' && p[j] == underline[i].search[0]; j++)
;
- 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);
(DIR) 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
+---