diff --git a/src/yaml/private/lexer.nim b/src/yaml/private/lexer.nim index 64a5f7e..ca37970 100644 --- a/src/yaml/private/lexer.nim +++ b/src/yaml/private/lexer.nim @@ -551,8 +551,7 @@ iterator tokens*(my: var YamlLexer): YamlLexerToken {.closure.} = of '\'': state = ylSingleQuotedScalar of '!': - my.content.add(c) - state = ylTagHandle + lastSpecialChar = '!' of '&': state = ylAnchor of '*': diff --git a/test/lexing.nim b/test/lexing.nim index c90a898..5974cfc 100644 --- a/test/lexing.nim +++ b/test/lexing.nim @@ -182,4 +182,15 @@ foo: test "Alias": ensure("foo: *bar", [t(yamlLineStart, ""), t(yamlScalar, "foo"), t(yamlColon, nil), t(yamlAlias, "bar"), - t(yamlStreamEnd, nil)]) \ No newline at end of file + t(yamlStreamEnd, nil)]) + + test "Tag handle": + ensure("!t!str tagged", [t(yamlLineStart, ""), t(yamlTagHandle, "!t!"), + t(yamlTagSuffix, "str"), + t(yamlScalar, "tagged"), t(yamlStreamEnd, nil)]) + + test "Verbatim tag handle": + ensure("! tagged", + [t(yamlLineStart, ""), + t(yamlVerbatimTag, "tag:http://example.com/str"), + t(yamlScalar, "tagged"), t(yamlStreamEnd, nil)]) \ No newline at end of file