feature. See also
. The project being documented here (as the example) is the Zig library itself.
Parser.startBlock
fn startBlock(p: *Parser, line: []const u8) !?BlockStart
File
Code
fn startBlock(p: *Parser, line: []const u8) !?BlockStart {
const unindented = mem.trimStart(u8, line, " \t");
const indent = line.len - unindented.len;
if (isThematicBreak(line)) {
return .{
.tag = .thematic_break,
.data = .{ .none = {} },
.rest = "",
};
} else if (startListItem(unindented)) |list_item| {
return .{
.tag = .list_item,
.data = .{ .list_item = .{
.marker = list_item.marker,
.number = list_item.number,
.continuation_indent = indent + list_item.marker_len,
} },
.rest = list_item.rest,
};
} else if (startTableRow(unindented)) |table_row| {
return .{
.tag = .table_row,
.data = .{ .table_row = .{
.cells_buffer = table_row.cells_buffer,
.cells_len = table_row.cells_len,
} },
.rest = "",
};
} else if (startHeading(unindented)) |heading| {
return .{
.tag = .heading,
.data = .{ .heading = .{
.level = heading.level,
} },
.rest = heading.rest,
};
} else if (try p.startCodeBlock(unindented)) |code_block| {
return .{
.tag = .code_block,
.data = .{ .code_block = .{
.tag = code_block.tag,
.fence_len = code_block.fence_len,
.indent = indent,
} },
.rest = "",
};
} else if (startBlockquote(unindented)) |rest| {
return .{
.tag = .blockquote,
.data = .{ .none = {} },
.rest = rest,
};
} else {
return null;
}
}