From 60804514534e714238444acde11c0e0f0b629180 Mon Sep 17 00:00:00 2001 From: Wilson Lin Date: Fri, 20 Jul 2018 22:39:28 +1200 Subject: [PATCH] Parse bangs --- src/main/c/stream/bang.c | 24 ++++++++++++++++++++++++ src/main/c/stream/content.c | 10 ++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/main/c/stream/bang.c diff --git a/src/main/c/stream/bang.c b/src/main/c/stream/bang.c new file mode 100644 index 0000000..bb29dcc --- /dev/null +++ b/src/main/c/stream/bang.c @@ -0,0 +1,24 @@ +#ifndef _HDR_HYPERBUILD_STREAM_BANG +#define _HDR_HYPERBUILD_STREAM_BANG + +#include "../util/hbchar.h" +#include "../util/pipe.c" + +void hbs_bang(hbu_pipe_t pipe) +{ + hbu_pipe_require_match(pipe, "') + { + break; + } + + hbu_pipe_skip(pipe); + } + + hbu_pipe_skip(pipe); +} + +#endif // _HDR_HYPERBUILD_STREAM_BANG diff --git a/src/main/c/stream/content.c b/src/main/c/stream/content.c index 696a4c9..55ee7fe 100644 --- a/src/main/c/stream/content.c +++ b/src/main/c/stream/content.c @@ -8,6 +8,7 @@ void hbs_content(hbu_pipe_t pipe); #include "./tag.c" +#include "./bang.c" void hbs_content(hbu_pipe_t pipe) { while (1) { @@ -21,9 +22,14 @@ void hbs_content(hbu_pipe_t pipe) { if (hbu_pipe_peek_offset(pipe, 2) == '/') { // Callee is responsible for requiring close tag (or not, if root) return; - } - hbs_tag(pipe); + } else if (hbu_pipe_peek_offset(pipe, 2) == '!') { + // Check after comment + hbs_bang(pipe); + + } else { + hbs_tag(pipe); + } break; case '&':