public Task TableInInclude() { List <Snippet> availableSnippets = new(); var content = @" some text include: theKey some other text "; List <string> lines = new() { @"| Number of Parameters | Variations per Parameter | Total Combinations | Pairwise Combinations | | -------------------- | ----------------------- | ------------------ | --------------------- | |2|5|25|25|" }; return(SnippetVerifier.Verify( DocumentConvention.SourceTransform, content, availableSnippets, includes: new[] { Include.Build("theKey", lines, "thePath") })); }
void Inner(List <Line> lines, Line line, List <Include> usedIncludes, int index, List <MissingInclude> missingIncludes) { var includeKey = line.Current.Substring(9); var include = includes.SingleOrDefault(x => string.Equals(x.Key, includeKey, StringComparison.OrdinalIgnoreCase)); if (include != null) { AddInclude(lines, line, usedIncludes, index, include); return; } if (includeKey.StartsWith("http")) { var(success, path) = Downloader.DownloadFile(includeKey).GetAwaiter().GetResult(); if (success) { include = Include.Build(includeKey, File.ReadAllLines(path), null); AddInclude(lines, line, usedIncludes, index, include); return; } } missingIncludes.Add(new MissingInclude(includeKey, index + 1, line.Path)); line.Current = $"** Could not find include '{includeKey}.include.md' **"; return; }
public Task SnippetInInclude() { List <Snippet> availableSnippets = new() { SnippetBuild("cs", "snippet1") }; var content = @" some text include: theKey some other text "; List <string> lines = new() { "snippet: snippet1" }; return(SnippetVerifier.Verify( DocumentConvention.SourceTransform, content, availableSnippets, includes: new[] { Include.Build("theKey", lines, "thePath") })); } [Fact]
public Task SnippetInIncludeLast() { var availableSnippets = new List <Snippet> { SnippetBuild( language: "cs", key: "snippet1" ) }; var content = @" some text include: theKey some other text "; var lines = new List <string> { "line1", "snippet: snippet1" }; return(this.VerifySnippets( content, availableSnippets, new List <string>(), includes: new[] { Include.Build("theKey", lines, "thePath") })); }
public Task Missing_endInclude() { var content = @" BAD <!-- include: theKey. path: /thePath --> "; return(SnippetVerifier.VerifyThrows <MarkdownProcessingException>( DocumentConvention.InPlaceOverwrite, content, includes: new[] { Include.Build("theKey", Array.Empty <string>(), "c:/root/thePath") })); }
public Task WithSingleInclude() { var content = @" before include: theKey after "; List <string> lines = new() { "theValue1" }; return(SnippetVerifier.Verify( DocumentConvention.SourceTransform, content, includes: new[] { Include.Build("theKey", lines, "c:/root/thePath") })); }
public Task WithSingleInclude_Overwrite() { var content = @" before BAD <!-- singleLineInclude: theKey. path: /thePath --> after "; List <string> lines = new() { "theValue1" }; return(SnippetVerifier.Verify( DocumentConvention.InPlaceOverwrite, content, includes: new[] { Include.Build("theKey", lines, "c:/root/thePath") })); }
public Task WithMultipleInclude() { var content = @" before include: theKey after "; var lines = new List <string> { "theValue1", "theValue2", "theValue3" }; return(this.VerifySnippets( content, availableSnippets: new List <Snippet>(), snippetSourceFiles: new List <string>(), includes: new[] { Include.Build("theKey", lines, "c:/root/thePath") })); }
public Task WithEmptyMultiLineInclude_Overwrite() { var content = @" before <!-- include: theKey. path: /thePath --> <!-- endInclude --> after "; List <string> lines = new() { "one", "two" }; return(SnippetVerifier.Verify( DocumentConvention.InPlaceOverwrite, content, includes: new[] { Include.Build("theKey", lines, "c:/root/thePath") })); }
public Task WithEmptyMultipleInclude() { var content = @" before include: theKey after "; var lines = new List <string> { "", "", "" }; return(SnippetVerifier.Verify( DocumentConvention.SourceTransform, content, includes: new[] { Include.Build("theKey", lines, "c:/root/thePath") })); }
public Task SnippetInIncludeLast() { List <Snippet> availableSnippets = new() { SnippetBuild("cs", "snippet1") }; var content = @" some text include: theKey some other text "; List <string> lines = new() { "line1", "snippet: snippet1" }; return(SnippetVerifier.Verify( DocumentConvention.SourceTransform, content, availableSnippets, includes: new[] { Include.Build("theKey", lines, "thePath") })); } static Snippet SnippetBuild(string language, string key) { return(Snippet.Build( language: language, startLine: 1, endLine: 2, value: "Snippet", key: key, path: "thePath")); } }