diff --git a/readme.md b/readme.md
index e935d9a1..0e9c277e 100644
--- a/readme.md
+++ b/readme.md
@@ -277,10 +277,11 @@ public enum LinkFormat
GitHub,
Tfs,
Bitbucket,
- GitLab
+ GitLab,
+ None
}
```
-snippet source | anchor
+snippet source | anchor
diff --git a/readme.source.md b/readme.source.md
index 769f0a6e..5e1425d7 100644
--- a/readme.source.md
+++ b/readme.source.md
@@ -262,6 +262,8 @@ mdsnippets --omit-snippet-links true
snippet: LinkFormat.cs
+Link format `None` will omit the source link but still keep the snippet anchor.
+
#### How links are constructed
diff --git a/schema.json b/schema.json
index dd4b08d1..78bed8c6 100644
--- a/schema.json
+++ b/schema.json
@@ -43,7 +43,8 @@
"Tfs",
"GitHub",
"Bitbucket",
- "GitLab"
+ "GitLab",
+ "None"
],
"pattern": "^.*$"
},
diff --git a/src/MarkdownSnippets/Processing/LinkFormat.cs b/src/MarkdownSnippets/Processing/LinkFormat.cs
index c22441cc..95b5540a 100644
--- a/src/MarkdownSnippets/Processing/LinkFormat.cs
+++ b/src/MarkdownSnippets/Processing/LinkFormat.cs
@@ -5,5 +5,6 @@ public enum LinkFormat
GitHub,
Tfs,
Bitbucket,
- GitLab
+ GitLab,
+ None
}
\ No newline at end of file
diff --git a/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs b/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs
index c96d9583..4bd4946c 100644
--- a/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs
+++ b/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs
@@ -24,7 +24,7 @@ public SnippetMarkdownHandling(string targetDirectory, LinkFormat linkFormat, bo
if (hashSnippetAnchors)
{
- getAnchorId = ComputeId;
+ getAnchorId = ComputeId;
}
else
{
@@ -68,7 +68,7 @@ string GetAnchorText(Snippet snippet, uint index)
return id;
}
- return $"{id}-{index}";
+ return $"{id}-{index}";
}
static string ComputeId(Snippet snippet)
@@ -81,7 +81,7 @@ static string ComputeId(Snippet snippet)
string GetSupText(Snippet snippet, string anchor)
{
var linkForAnchor = $"anchor";
- if (snippet.Path == null)
+ if (snippet.Path == null || linkFormat == LinkFormat.None)
{
return linkForAnchor;
}
diff --git a/src/Tests/SnippetMarkdownHandlingTests.AppendOmitSourceLink.verified.txt b/src/Tests/SnippetMarkdownHandlingTests.AppendOmitSourceLink.verified.txt
new file mode 100644
index 00000000..eb340783
--- /dev/null
+++ b/src/Tests/SnippetMarkdownHandlingTests.AppendOmitSourceLink.verified.txt
@@ -0,0 +1,5 @@
+
+```thelanguage
+theValue
+```
+anchor
diff --git a/src/Tests/SnippetMarkdownHandlingTests.cs b/src/Tests/SnippetMarkdownHandlingTests.cs
index a798d32e..e54ae00c 100644
--- a/src/Tests/SnippetMarkdownHandlingTests.cs
+++ b/src/Tests/SnippetMarkdownHandlingTests.cs
@@ -1,4 +1,4 @@
-using MarkdownSnippets;
+using MarkdownSnippets;
[UsesVerify]
public class SnippetMarkdownHandlingTests
@@ -17,6 +17,20 @@ public Task Append()
return Verify(builder.ToString());
}
+ [Fact]
+ public Task AppendOmitSourceLink()
+ {
+ var builder = new StringBuilder();
+ var snippets = Snippets();
+ var markdownHandling = new SnippetMarkdownHandling("c:/dir/", LinkFormat.None, false, false);
+ using (var writer = new StringWriter(builder))
+ {
+ markdownHandling.Append("key1", snippets, writer.WriteLine);
+ }
+
+ return Verify(builder.ToString());
+ }
+
[Fact]
public Task AppendOmitSnippetLinks()
{