public static EMElements ExcerptLazyParser(EMDocument doc, EMElement parent, string content, TransformationData data) { content = Preprocessor.CutoutComments(content, null); var elements = new EMElements(doc, new EMElementOrigin(0, content), parent); var previousCurrentFolder = data.CurrentFolderDetails.CurrentFolderFromMarkdownAsTopLeaf; var newCurrentFolder = doc.GetAbsoluteMarkdownPath(); data.CurrentFolderDetails.CurrentFolderFromMarkdownAsTopLeaf = newCurrentFolder; elements.Parse(content, data); data.CurrentFolderDetails.CurrentFolderFromMarkdownAsTopLeaf = previousCurrentFolder; return(elements); }
public static EMElements ExcerptLazyParser(EMDocument doc, EMElement parent, string content, TransformationData data) { content = Preprocessor.CutoutComments(content, null); var elements = new EMElements(doc, new EMElementOrigin(0, content), parent); var previousCurrentFolder = data.CurrentFolderDetails.CurrentFolderFromMarkdownAsTopLeaf; var newCurrentFolder = doc.GetAbsoluteMarkdownPath(); data.CurrentFolderDetails.CurrentFolderFromMarkdownAsTopLeaf = newCurrentFolder; elements.Parse(content, data); data.CurrentFolderDetails.CurrentFolderFromMarkdownAsTopLeaf = previousCurrentFolder; return elements; }
private static EMElement Create( Match match, EMDocument doc, EMElementOrigin origin, EMElement parent, TransformationData data) { var includeFileFolderName = ""; var includeRegion = ""; var thisOffset = 0; if (match.Groups["includeFileRegion"].Value.Contains('#')) { includeFileFolderName = match.Groups["includeFileRegion"].Value.Split('#')[0]; includeRegion = match.Groups["includeFileRegion"].Value.Split('#')[1]; if (!includeRegion.StartsWith("doxygen")) { includeRegion = includeRegion.ToLower(); } } else { includeFileFolderName = match.Groups["includeFileRegion"].Value; } if (includeFileFolderName.ToUpper().Contains("%ROOT%")) { includeFileFolderName = "."; } if (String.IsNullOrWhiteSpace(includeFileFolderName)) { if (String.IsNullOrWhiteSpace(includeRegion)) { // Error cannot have no region and no file specified. return(EMErrorElement.Create( data.Document, origin, parent, data, "ExcerptRegionToIncludeWhenNoFileGiven")); } // Assume that this is a reference to a location in this file. includeFileFolderName = doc.GetAbsoluteMarkdownPath(); } if (!String.IsNullOrWhiteSpace(match.Groups["offsetValue"].Value) && !int.TryParse(match.Groups["offsetValue"].Value, out thisOffset)) { return(EMErrorElement.Create( data.Document, origin, parent, data, "ValueMustBeNumber")); } try { bool languageChanged; var excerpt = ExcerptsManager.Get(data.ProcessedDocumentCache, Path.Combine(data.CurrentFolderDetails.AbsoluteMarkdownPath, includeFileFolderName), data.CurrentFolderDetails.Language, includeRegion, out languageChanged); return(new EMInclude(doc, origin, parent, excerpt, thisOffset, languageChanged)); } catch (ExcerptsManagerException e) { return(EMErrorElement.Create(doc, origin, parent, data, e.MessageId, e.MessageArgs)); } }