From fd385801d115e8a0aa29ffb9b9e6ff215c34cc42 Mon Sep 17 00:00:00 2001 From: Linnnus Date: Sat, 17 Feb 2024 02:41:43 +0100 Subject: fix(creole): Handle escapes properly A faulty boolean expression was to blame. This patch also adds the necessary tests to prevent relapses (i forgot det technical term). --- src/creole.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/creole.c') diff --git a/src/creole.c b/src/creole.c index 5804ebd..94e8020 100644 --- a/src/creole.c +++ b/src/creole.c @@ -116,6 +116,8 @@ static struct { // Escaped special characters {"~[[", "[["}, {"~]]", "]]"}, // NOTE: This pattern is duplicated in do_link(). + {"~//", "//"}, + {"~**", "**"}, // Characters that have special meaning in HTML // NOTE: These rules are duplicated in hprint(). {"<", "<"}, @@ -256,7 +258,7 @@ long do_emphasis(const char *begin, const char *end, bool new_block, FILE *out) const char *stop = start; do { stop = strnstr(stop + 1, "//", end - (stop + 1)); - } while (stop != NULL && stop[-1] == '~' && stop[-1] == ':'); + } while (stop != NULL && (stop[-1] == '~' || stop[-1] == ':')); if (stop == NULL) { return 0; } -- cgit v1.2.3