feat: add heading tokenizer (#1723)

This commit is contained in:
boojack
2023-05-23 19:52:31 +08:00
committed by GitHub
parent 616b8b0ee6
commit fa53a2550a
5 changed files with 191 additions and 50 deletions

View File

@@ -32,9 +32,44 @@ func TestTokenize(t *testing.T) {
},
},
},
{
text: `# hello
world`,
tokens: []*Token{
{
Type: Hash,
Value: "#",
},
{
Type: Space,
Value: " ",
},
{
Type: Text,
Value: "hello",
},
{
Type: Space,
Value: " ",
},
{
Type: Newline,
Value: "\n",
},
{
Type: Space,
Value: " ",
},
{
Type: Text,
Value: "world",
},
},
},
}
for _, test := range tests {
result := tokenize(test.text)
result := Tokenize(test.text)
require.Equal(t, test.tokens, result)
}
}