public static EmphasisInline TryParse(CreoleReader reader) { if (reader.Peek(2) != "//" || HasLinkPrefix(reader)) return null; int index = 0; while (true) { index = reader.IndexOf("//", index + 2); if (index == -1) break; if (!HasLinkPrefix(reader, index)) break; } reader.Skip(2); string content; if (index != -1) { content = reader.Read(index - 2); reader.Skip(2); } else { content = reader.ReadToEnd(); } return new EmphasisInline(content); }
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; }
public static NoWikiInline TryParse(CreoleReader reader) { if (reader.Peek(3) != "{{{") return null; var index = reader.IndexOf("}}}", 2); if (index == -1) return null; reader.Skip(3); var content = reader.Read(index - 3); reader.Skip(3); return new NoWikiInline(content); }
public static StrongInline TryParse(CreoleReader reader) { if (reader.Peek(2) != "**") return null; var index = reader.IndexOf("**", 2); reader.Skip(2); string content; if (index != -1) { content = reader.Read(index - 2); reader.Skip(2); } else { content = reader.ReadToEnd(); } return new StrongInline(content); }
public static ImageInline TryParse(CreoleReader reader) { if (reader.Peek(2) != "{{") return null; var index = reader.IndexOf("}}", 2); if (index == -1) return null; reader.Skip(2); var content = reader.Read(index - 2); reader.Skip(2); index = content.IndexOf("|"); if (index == -1) return new ImageInline(content, null); var url = content.Substring(0, index); var alt = content.Substring(index + 1, content.Length - index - 1); return new ImageInline(url, alt); }