public static HorizontalLineBlock TryParse(CreoleReader reader)
		{
			var line = reader.PeekLine().Trim();

			if (!line.StartsWith("----"))
				return null;

			if (line.Any(c => c != '-'))
				return null;

			reader.SkipLine();
			return new HorizontalLineBlock();
		}
		public static IEnumerable<ParagraphBlock> Parse(string paragraphs)
		{
			var reader = new CreoleReader(paragraphs);

			while (!reader.EndOfMarkup)
			{
				var content = reader.ReadLineUntil(l => l.Trim().Length <= 0 ? l.Length : -1);

				if (content == null)
					content = reader.ReadToEnd();
				else
					reader.SkipLine();

				if (content.Trim().Length <= 0)
					continue;

				yield return new ParagraphBlock(content.Trim());
			}
		}
Esempio n. 3
0
		public static HeadingBlock TryParse(CreoleReader reader)
		{
			var line = reader.PeekLine().Trim();

			if (!line.StartsWith("="))
				return null;

			var level = 0;
			for (level = 1; level < 6; level++)
				if (line[level] != '=') break;

			var endIndex = 0;
			for (endIndex = line.Length - 1; endIndex >= line.Length - level; endIndex--)
				if (line[endIndex] != '=') break;

			reader.SkipLine();

			var content = line.Substring(level, endIndex - (level - 1));

			return new HeadingBlock(level, content);
		}