diff --git a/lib/GrottyParser/GrottyParser.xs b/lib/GrottyParser/GrottyParser.xs
index 4ec8489..99c4a03 100644
--- a/lib/GrottyParser/GrottyParser.xs
+++ b/lib/GrottyParser/GrottyParser.xs
@@ -95,6 +95,37 @@ static void flushchunk(ctx_t *x, const char *s, const char *f, const char *e) {
#define ismanchar(x) (isalnum(x) || x == '_' || x == '-' || x == '.')
+static void flushinclude(ctx_t *x) {
+ char buf[8] = {};
+ char *s = x->line;
+
+ s[x->linelen-3] = 0;
+ s += 17;
+ char *fn = strrchr(s, '/');
+ fn = fn ? fn+1 : s;
+ sv_catpv(x->dest, ">> Included manual page: dest, buf, 1);
+ }
+
+ sv_catpv(x->dest, "\">");
+ sv_catpv(x->dest, s);
+ sv_catpv(x->dest, "");
+}
+
+
// HTML-escapes and "Flushes" the current line to the output string. Tries to
// convert man references and URLs into links if format is true.
static void flushline(ctx_t *x) {
@@ -103,11 +134,7 @@ static void flushline(ctx_t *x) {
// Special-case [[[MANNEDINCLUDE ..]]] directive
if(x->linelen > 20 && *s == '[' && strncmp(s, "[[[MANNEDINCLUDE ", 17) == 0 && strcmp("]]]", s+x->linelen-3) == 0) {
- s[x->linelen-3] = 0;
- s += 17;
- char *fn = strrchr(s, '/');
- fn = fn ? fn+1 : s;
- sv_catpvf(x->dest, ">> Included manual page: %s", fn, s);
+ flushinclude(x);
goto end;
}