Skip to content

Commit dd04948

Browse files
committed
fixed a markup interpolation bug with bools
1 parent 7ab8745 commit dd04948

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1010

1111
### Updated
1212

13+
- Fixed a bug where interpolated boolean values inside markup were being incorrectly determined as a string and not a bool.
14+
1315
### Removed
1416

1517
## [3.0.1] 2025-06-12

YarnSpinner.Tests/MarkupTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,13 @@ public void TestMarkupMultiplePropertyParsing()
10831083
[InlineData("[a p={$someValue}]s[/a]", MarkupValueType.String, "$someValue")]
10841084
[InlineData("[p=-1 /]", MarkupValueType.Integer, "-1")]
10851085
[InlineData("[p=-1.1 /]", MarkupValueType.Float, "-1.1")]
1086+
[InlineData("[p={$someValue}]s[/p]", MarkupValueType.String, "$someValue")]
1087+
[InlineData("[p=True]s[/p]", MarkupValueType.Bool, "True")]
1088+
[InlineData("[p=true]s[/p]", MarkupValueType.Bool, "True")]
1089+
[InlineData("[p=False]s[/p]", MarkupValueType.Bool, "False")]
1090+
[InlineData(@"[p=""string""]s[/p]", MarkupValueType.String, "string")]
1091+
[InlineData("[p=string]s[/p]", MarkupValueType.String, "string")]
1092+
[InlineData(@"[p=""str\""ing""]s[/p]", MarkupValueType.String, @"str""ing")]
10861093
public void TestMarkupPropertyParsing(string input, MarkupValueType expectedType, string expectedValueAsString)
10871094
{
10881095
var lineParser = new LineParser();

YarnSpinner/YarnSpinner.Markup/LineParser.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,9 @@ internal List<LexerToken> LexMarkup(string input)
641641
// ok so now we have accumulated all the value characters
642642
// which we now want to do some quick checks on, is it true or false
643643
var value = input.Substring(token.Start, currentPosition + 1 - token.Start);
644-
if (value == "true" || value == "false")
644+
if (value == "true" || value == "True" || value == "false" || value == "False")
645645
{
646-
// This was the word 'true' or 'false', so this
646+
// This was the word '[T]rue' or '[F]alse', so this
647647
// is a boolean value and not an undelimited
648648
// string
649649
token.Type = LexerTokenTypes.BooleanValue;
@@ -967,13 +967,15 @@ bool TryFloatFromToken(LexerToken token, out float value)
967967
}
968968
bool TryBoolFromToken(LexerToken token, out bool value)
969969
{
970+
// at this point the lexer has determined that it is either a true or false value
971+
// so we are safe to do the ignore case check
970972
var valueString = OG.Substring(token.Start, token.Range);
971-
if (valueString == "true")
973+
if (valueString.Equals("true", StringComparison.OrdinalIgnoreCase))
972974
{
973975
value = true;
974976
return true;
975977
}
976-
if (valueString == "false")
978+
if (valueString.Equals("false", StringComparison.OrdinalIgnoreCase))
977979
{
978980
value = false;
979981
return true;

0 commit comments

Comments
 (0)