示例#1
0
		public static LinkInline TryParse(CreoleReader reader)
		{
			if (reader.Peek(2) == "[[")
			{
				var index = reader.IndexOf("]]", 2);
				if (index == -1)
					return null;

				reader.Skip(2);
				var data = reader.Read(index - 2);
				reader.Skip(2);

				index = data.IndexOf("|");
				if (index == -1)
					return new LinkInline(data, data, parseContent: false);

				var url = data.Substring(0, index);
				var content = data.Substring(index + 1, data.Length - index - 1);

				return new LinkInline(url, content);
			}
			else if (reader.IsNewWord && UrlRegex.IsMatch(reader.NextWord))
			{
				var url = reader.ReadWord();

				return new LinkInline(url, url, parseContent: false);
			}

			return null;
		}