From fa43fd7e2786223276d3d81af0599c3abef2a61c Mon Sep 17 00:00:00 2001 From: david parsons Date: Fri, 18 Jan 2008 14:04:20 -0800 Subject: [PATCH] Support --- theme.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/theme.c b/theme.c index e60776a..72b6bdf 100644 --- a/theme.c +++ b/theme.c @@ -183,6 +183,36 @@ istag(int *p, char *pat) } +static void +includefile(int *pat, FILE *out) +{ + int c; + int i; + Cstring include; + FILE *f; + + CREATE(include); + + for (i=0; pat[i] && (pull() == pat[i]); i++) + ; + + while ( (c=pull()) != ')' && c != EOF ) + EXPAND(include) = c; + + if ( c != EOF ) { + EXPAND(include) = 0; + S(include)--; + + if (( f = fopen(T(include), "r") )) { + while ( (c = getc(f)) != EOF ) + putc(c, out); + fclose(f); + } + } + DELETE(include); +} + + /* spin() - run through the theme template, looking for -- the document name * -- the html file name * -- document-supplied style blocks + * -- include a file. */ void spin(FILE *template, MMIOT doc, FILE *output) @@ -269,6 +300,8 @@ spin(FILE *template, MMIOT doc, FILE *output) if ( inhead ) mkd_style(doc,output); } + else if ( thesame(p, "include(") ) + includefile(p,output); while ( (c = pull()) != EOF && (c != '?' && peek(1) != '>') ) ;