public void Read()
		{
			var reader = new CreoleReader("1234567890");

			var actual = reader.Read(5);

			Assert.AreEqual("12345", actual);
			Assert.AreEqual(5, reader.Position);
		}
Esempio n. 2
0
		internal string ParseInlines(string markup, params Func<CreoleReader, CreoleElement>[] ignore)
		{
			var elements = new List<InlineElement>();

			// parse markup
			var reader = new CreoleReader(markup);

			var textBuilder = new StringBuilder();
			while (!reader.EndOfMarkup)
			{
				InlineElement inline = null;

				foreach (var inlineParser in InlineElements)
				{
					if (ignore.Contains(inlineParser))
						continue;

					inline = inlineParser(reader);
					if (inline == null)
						continue;

					break;
				}

				if (inline == null)
				{
					textBuilder.Append(reader.Read(1));
				}
				else
				{
					elements.AddRange(TextInline.Parse(textBuilder.ToString()));
					textBuilder.Clear();

					elements.Add(inline);
				}
			}
			if (textBuilder.Length > 0)
				elements.AddRange(TextInline.Parse(textBuilder.ToString()));

			// render output
			var writer = new CreoleWriter();

			foreach (var element in elements)
			{
				element.Render(this, writer);
			}

			return writer.ToString().Replace("\n", Environment.NewLine);
		}