private static EMElement CreateParagraph(Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data) { var contentGroup = match.Groups["content"]; var spanContent = new EMSpanElements(doc, new EMElementOrigin(origin.Start, contentGroup.Value), parent); spanContent.Parse(contentGroup.Value, data); return(new EMParagraph(doc, origin, parent, spanContent)); }
public TableCellInformation( EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data, int colSpanCount = 1, string alignment = null, bool isRowHeader = false, bool isDummy = false, int rowSpanCount = 1, bool isRowSpanColumn = false) : this(colSpanCount, alignment, isRowHeader, isDummy, rowSpanCount, isRowSpanColumn) { Content = new EMSpanElements(doc, origin, parent); Content.Parse(0, origin.Text, data); }
public static EMElement CreateFromAnchorRefShortcut(Match match, EMDocument doc, EMElementOrigin orig, EMElement parent, TransformationData data) { var linkText = match.Groups[2].Value; var linkId = Regex.Replace(linkText.ToLowerInvariant(), @"[ ]*\n[ ]*", " "); if (!data.ReferenceLinks.Urls.ContainsKey(linkId)) { throw new EMSkipParsingException(); } var url = data.ReferenceLinks.Urls[linkId]; var content = new EMSpanElements( doc, new EMElementOrigin(orig.Start + match.Groups[2].Index, linkText), parent); content.Parse(match.Groups[2].Value, data); return(Create(doc, orig, parent, data, content, url, GetReferenceTitle(data, linkId))); }
public void Parse(EMDocument doc, Match match, TransformationData data) { var itemContent = match.Groups["listItemContent"]; var lineEnding = itemContent.Value.IndexOf('\n'); var definitionSeparator = itemContent.Value.LastIndexOf(':', lineEnding); var dt = itemContent.Value.Substring(0, definitionSeparator > 0 ? definitionSeparator : itemContent.Length); Declaration = new EMSpanElements(doc, new EMElementOrigin(itemContent.Index - Origin.Start, dt), this); Declaration.Parse(dt, data); if (definitionSeparator > 0) { var dd = itemContent.Value.Substring(definitionSeparator + 1); Elements = new EMElements(doc, new EMElementOrigin(itemContent.Index + definitionSeparator + 1 - Origin.Start, dd), this); Elements.Parse(0, Markdown.Outdent(dd, Elements.TextMap), data); } else { Elements = null; } }
private static EMElement Create( EMDocument doc, EMElementOrigin orig, EMElement parent, TransformationData data, EMSpanElements content, string path, string title) { try { bool isAPILink = false; string APIMember = ""; if (path.StartsWith("API:")) { APIMember = path.Substring(4, path.Length - 4); if (Markdown.APIFileLocation.ContainsKey(APIMember)) { path = "https://docs.unrealengine.com/latest/INT/" + Markdown.APIFileLocation[APIMember].Replace("\\", "/") + "/index.html"; } else { content.Parse(APIMember, data); return(content); } isAPILink = true; } var pathProvider = EMPathProvider.CreatePath(path, doc, data); var errorId = -1; if (pathProvider is EMLocalFilePath) { var filePath = pathProvider as EMLocalFilePath; if (!filePath.IsImage) { data.AttachNames.Add( new AttachmentConversionDetail(filePath.GetSource(), filePath.GetAbsolutePath(data))); } else { data.ImageDetails.Add( new ImageConversion( filePath.GetSource(), filePath.GetAbsolutePath(data), 0, 0, false, null, Color.Transparent, 0)); } } if (content.ElementsCount == 0) { if (pathProvider.IsBookmark) { errorId = data.ErrorList.Count; data.ErrorList.Add( Markdown.GenerateError( Language.Message("LinkTextMustBeProvidedForBookmarkLinks", orig.Text), MessageClass.Error, Markdown.Unescape(orig.Text), errorId, data)); } else if (pathProvider is EMLocalDocumentPath) { if (isAPILink) { content.Parse(APIMember, data); } else { content.Parse( data.ProcessedDocumentCache.Variables.ReplaceVariables( content.Document, "%" + path + ":title%", data), data); } } else if (pathProvider is EMLocalFilePath) { if (isAPILink) { content.Parse(APIMember, data); } else { // If no link text provided use the file name. content.Parse(Regex.Replace(pathProvider.GetPath(data), @".*[\\|/](.*)", "$1"), data); } } else { if (isAPILink) { content.Parse(APIMember, data); } else { // If no link text provided use the url (remove protocol, e.g. ftp:// http://). content.Parse(Regex.Replace(pathProvider.GetPath(data), @"([^:]+://)?(.*)", "$2"), data); } } } if (errorId != -1) { return(new EMErrorElement(doc, orig, parent, errorId)); } if (isAPILink) { return(new EMLink(doc, orig, parent, data, pathProvider, APIMember, content)); } else { return(new EMLink(doc, orig, parent, data, pathProvider, title, content)); } } catch (EMPathVerificationException e) { if (doc.PerformStrictConversion()) { return(new EMErrorElement(doc, orig, parent, e.AddToErrorList(data, orig.Text))); } else { EMFormattedText Text = new EMFormattedText(doc, orig, parent); Text.Parse(orig.Text, data); return(Text); } } }