authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-06 02:23:41 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-06 02:23:41 -07:00
log791a3f5dcd2498c6ced5f1800f1921e63f54f12b
treeb90c07688d1d501a0dfe74b84a9cabec39e47d5d
parent250e56a7821a3c6db9453ded696f9f3c622c94b0

change replacement syntax to separate with periods instead of spaces


3 files changed, 4 insertions(+), 2 deletions(-)

src/astgen.zig+2
...@@ -152,7 +152,9 @@ const Parser = struct {...@@ -152,7 +152,9 @@ const Parser = struct {
152152
153 pub fn doReplacement(comptime self: *Parser) []const string {153 pub fn doReplacement(comptime self: *Parser) []const string {
154 var ret: []const string = &.{};154 var ret: []const string = &.{};
155 ret = ret ++ &[_]string{self.eat(.word)};
155 while (!self.tryEatSymbol("}")) {156 while (!self.tryEatSymbol("}")) {
157 self.eatSymbol(".");
156 ret = ret ++ &[_]string{self.eat(.word)};158 ret = ret ++ &[_]string{self.eat(.word)};
157 }159 }
158 return ret;160 return ret;
src/lib.zig+1-1
...@@ -29,7 +29,7 @@ const tokenize = @import("./tokenize.zig");...@@ -29,7 +29,7 @@ const tokenize = @import("./tokenize.zig");
29const astgen = @import("./astgen.zig");29const astgen = @import("./astgen.zig");
3030
31pub fn parse(comptime input: []const u8) astgen.Value {31pub fn parse(comptime input: []const u8) astgen.Value {
32 return astgen.Value{ .element = astgen.do(tokenize.do(input, &.{ '[', '=', ']', '(', ')', '{', '}', '#', '/' })) };32 return astgen.Value{ .element = astgen.do(tokenize.do(input, &.{ '[', '=', ']', '(', ')', '{', '}', '#', '/', '.' })) };
33}33}
3434
35pub fn compile(writer: anytype, comptime value: astgen.Value, data: anytype) !void {35pub fn compile(writer: anytype, comptime value: astgen.Value, data: anytype) !void {
src/main.zig+1-1
...@@ -13,7 +13,7 @@ const example_document =...@@ -13,7 +13,7 @@ const example_document =
13 \\ hr13 \\ hr
14 \\ p("This is an example HTML document written in "a[href="https://github.com/nektro/zig-pek"]("Pek")".")14 \\ p("This is an example HTML document written in "a[href="https://github.com/nektro/zig-pek"]("Pek")".")
15 \\ p("Pek is written by "{author}".")15 \\ p("Pek is written by "{author}".")
16 \\ p("Her favorite plant is the "{favorite flower})16 \\ p("Her favorite plant is the "{favorite.flower})
17 \\ br17 \\ br
18 \\ p("The most populous US cities are:")18 \\ p("The most populous US cities are:")
19 \\ ul(19 \\ ul(