commit 726d9a6e85aaf98285e12f3f027b770ad69d36a0
parent 3ea11dbb9be06bccb0916b305fab943071973021
Author: Ed van Bruggen <ed@edryd.org>
Date: Wed, 18 Jun 2025 18:46:28 -0400
Escape backslashes in inline code
Diffstat:
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/markman.c b/markman.c
@@ -65,6 +65,7 @@ struct Block {
Block next;
};
+
void
die(int eval, const char *fmt, ...)
{
@@ -82,6 +83,7 @@ die(int eval, const char *fmt, ...)
exit(eval);
}
+
static char*
str_cap(char *s)
{
@@ -273,7 +275,18 @@ markman_parse(char *src)
}
}
-void disp_line(Line l)
+static void
+print_esc(const char *str)
+{
+ for (; *str; str++) {
+ if (*str == '\\')
+ putchar('\\');
+ putchar(*str);
+ }
+}
+
+void
+disp_line(Line l)
{
switch (l->t) {
case LINK:
@@ -287,7 +300,9 @@ void disp_line(Line l)
printf("\\fI%s\\fP", l->v.s);
break;
case LCODE:
- printf("'%s'", l->v.s);
+ putchar('\'');
+ print_esc(l->v.s);
+ putchar('\'');
break;
}
if (l->next)