diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-26 23:10:17 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-26 23:17:26 +0200 |
| commit | de948492e8b38a79d5db9c506c1b7b82e86c6b12 (patch) | |
| tree | 122e4c004d37193c64d6b8b89d9a252f7e237cfa /src/lexer | |
| parent | ae6ee68d6f4ef79fef609b4d09b543fc06326e95 (diff) | |
feat(): support code block
Diffstat (limited to 'src/lexer')
| -rw-r--r-- | src/lexer/Lexer.zig | 9 | ||||
| -rw-r--r-- | src/lexer/Token.zig | 11 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/lexer/Lexer.zig b/src/lexer/Lexer.zig index 983aa23..4137b40 100644 --- a/src/lexer/Lexer.zig +++ b/src/lexer/Lexer.zig @@ -54,7 +54,7 @@ pub fn next(self: *Self) ?Token { // conds here to avoid creating complex condition in while const next_rune = self.iter.peek(1); const next_kind = self.getCurrentKind(current_kind, next_rune, self.content[beg..end]).kind; - if (requiresSpace(current_kind.?) and next_kind != current_kind.?) { + if (current_kind.?.requiresSpace() and next_kind != current_kind.?) { if (eql(u8, next_rune, " ")) { // consume next space _ = self.iter.nextCodepoint(); @@ -166,13 +166,6 @@ fn isOneOrThree(op: []const u8, rune: []const u8, p: []const u8, one: Token.Kind }; } -fn requiresSpace(k: Token.Kind) bool { - return switch (k) { - .title, .list_ordored, .list_unordored => true, - else => false, - }; -} - fn doTest(l: *Self, k: Token.Kind, v: []const u8) !void { var first = l.next().?; std.testing.expect(first.equals(k, v)) catch |err| { diff --git a/src/lexer/Token.zig b/src/lexer/Token.zig index bd2a07b..bd0bdc2 100644 --- a/src/lexer/Token.zig +++ b/src/lexer/Token.zig @@ -21,19 +21,26 @@ pub const Kind = enum { list_unordored, tag, - pub fn isDelimiter(self: @This()) bool { + pub inline fn isDelimiter(self: @This()) bool { return switch (self) { .weak_delimiter, .strong_delimiter => true, else => false, }; } - pub fn isPar(self: @This()) bool { + pub inline fn isPar(self: @This()) bool { return switch (self) { .literal, .link, .code, .math, .bold, .italic, .ref => true, else => false, }; } + + pub inline fn requiresSpace(self: @This()) bool { + return switch (self) { + .title, .list_ordored, .list_unordored => true, + else => false, + }; + } }; kind: Kind, |
