Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ A [dotnet tool](https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools)

Support is available via a [Tidelift Subscription](https://tidelift.com/subscription/pkg/nuget-markdownsnippets?utm_source=nuget-markdownsnippets&utm_medium=referral&utm_campaign=enterprise).

<!-- toc -->
## Contents

* [Value Proposition](#value-proposition)
* [Behavior](#behavior)
* [Installation](#installation)
* [Usage](#usage)
* [Defining Snippets](#defining-snippets)
* [Using Snippets](#using-snippets)
* [Add to Windows Explorer](#add-to-windows-explorer)
* [More Documentation](#more-documentation)
* [Security contact information](#security-contact-information)<!-- endToc -->


## Value Proposition

Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591</NoWarn>
<Version>23.1.1</Version>
<Version>23.1.2</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageTags>Markdown, Snippets, mdsnippets, documentation, MarkdownSnippets</PackageTags>
<Description>Extracts snippets from code files and merges them into markdown documents.</Description>
Expand Down
3 changes: 2 additions & 1 deletion src/MarkdownSnippets/Processing/MarkdownProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ Snippet FileToSnippet(string key, string file, string? path)
{
var cleanedLines = File.ReadAllLines(file)
.Where(x => !StartEndTester.IsStartOrEnd(x.TrimStart())).ToList();
return (string.Join(newLine, cleanedLines), cleanedLines.Count);
var text = string.Join(newLine, cleanedLines).Trim();
return (text, cleanedLines.Count);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Local

snippet: sourceFile.txt

Relative Local

snippet: ./sourceFile.txt

Rooted

snippet: /sourceFile.txt

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@



From Source File



Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Local

<!-- snippet: sourceFile.txt -->
<a id='snippet-sourceFile.txt'></a>
```txt
From Source File
```
<sup><a href='/sourceFile.txt#L1-L5' title='Snippet source file'>snippet source</a> | <a href='#snippet-sourceFile.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Relative Local

<!-- snippet: ./sourceFile.txt -->
<a id='snippet-./sourceFile.txt'></a>
```txt
From Source File
```
<sup><a href='#snippet-./sourceFile.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Rooted

<!-- snippet: /sourceFile.txt -->
<a id='snippet-/sourceFile.txt'></a>
```txt
From Source File
```
<sup><a href='/sourceFile.txt#L1-L5' title='Snippet source file'>snippet source</a> | <a href='#snippet-/sourceFile.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Local

<!-- snippet: sourceFile.txt -->
<a id='snippet-sourceFile.txt'></a>
```txt
From Source File
```
<sup><a href='/sourceFile.txt#L1-L7' title='Snippet source file'>snippet source</a> | <a href='#snippet-sourceFile.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Relative Local

<!-- snippet: ./sourceFile.txt -->
<a id='snippet-./sourceFile.txt'></a>
```txt
From Source File
```
<sup><a href='#snippet-./sourceFile.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Rooted

<!-- snippet: /sourceFile.txt -->
<a id='snippet-/sourceFile.txt'></a>
```txt
From Source File
```
<sup><a href='/sourceFile.txt#L1-L7' title='Snippet source file'>snippet source</a> | <a href='#snippet-/sourceFile.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

16 changes: 16 additions & 0 deletions src/Tests/DirectoryMarkdownProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,22 @@ public Task BinaryFileSnippet()
return Verifier.Verify(File.ReadAllTextAsync(result));
}

[Fact]
public Task FileSnippetWithWhiteSpace()
{
var root = Path.GetFullPath("DirectoryMarkdownProcessor/FileSnippetWithWhiteSpace");
DirectoryMarkdownProcessor processor = new(
root,
writeHeader: false,
directoryIncludes: _ => true,
markdownDirectoryIncludes: _ => true,
snippetDirectoryIncludes: _ => true);
processor.Run();

var result = Path.Combine(root, "one.md");

return Verifier.Verify(File.ReadAllTextAsync(result));
}

[Fact]
public Task FileSnippet()
Expand Down