Browse Source

Fixed text node concatenation

lord-executor 8 năm trước cách đây
mục cha
commit
85814edaed

+ 3 - 0
Parser.Tests/Integration/ParserIntegrationTests.cs

@@ -4,6 +4,7 @@ using NUnit.Framework;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.IO;
 using System.IO;
+using System.Linq;
 using System.Text;
 using System.Text;
 
 
 namespace Larkdown.Parser.Tests.Integration
 namespace Larkdown.Parser.Tests.Integration
@@ -46,6 +47,8 @@ namespace Larkdown.Parser.Tests.Integration
 
 
 			ast.Nodes.Should().HaveCount(3);
 			ast.Nodes.Should().HaveCount(3);
 			ast.Nodes.Should().AllBeOfType<TextNode>();
 			ast.Nodes.Should().AllBeOfType<TextNode>();
+
+			ast.Nodes.First().As<TextNode>().Text.Should().Be("This is a paragraph that spans over multiple lines.");
 		}
 		}
     }
     }
 }
 }

+ 1 - 1
Parser/Ast/TextNode.cs

@@ -16,7 +16,7 @@ namespace Larkdown.Parser.Ast
 
 
 		public TextNode AddText(string text)
 		public TextNode AddText(string text)
 		{
 		{
-			Text += text;
+			Text += String.IsNullOrEmpty(Text) ? text : " " + text;
 			return this;
 			return this;
 		}
 		}