Skip to content

Commit

Permalink
add Bitbucket and GitLab support
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Aug 17, 2019
1 parent 4d7d0e8 commit a6e033d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
16 changes: 13 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,13 @@ namespace MarkdownSnippets
public enum LinkFormat
{
GitHub,
Tfs
Tfs,
Bitbucket,
GitLab
}
}
```
<sup>[snippet source](/src/MarkdownSnippets/Processing/LinkFormat.cs#L1-L8) / [anchor](#snippet-LinkFormat.cs)</sup>
<sup>[snippet source](/src/MarkdownSnippets/Processing/LinkFormat.cs#L1-L10) / [anchor](#snippet-LinkFormat.cs)</sup>
<!-- endsnippet -->

<!-- snippet: BuildLink -->
Expand All @@ -287,8 +289,16 @@ if (linkFormat == LinkFormat.Tfs)
{
return $"{path}&line={snippet.StartLine}&lineEnd={snippet.EndLine}";
}
if (linkFormat == LinkFormat.Bitbucket)
{
return $"{path}#lines={snippet.StartLine}:{snippet.EndLine}";
}
if (linkFormat == LinkFormat.GitLab)
{
return $"{path}#L{snippet.StartLine}-{snippet.EndLine}";
}
```
<sup>[snippet source](/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs#L72-L81) / [anchor](#snippet-buildlink)</sup>
<sup>[snippet source](/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs#L72-L89) / [anchor](#snippet-buildlink)</sup>
<!-- endsnippet -->


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>16.2.0</Version>
<Version>16.3.0</Version>
<PackageTags>Markdown, Snippets, mdsnippets, documentation, MarkdownSnippets</PackageTags>
<Description>Extracts snippets from code files and merges them into markdown documents.</Description>
</PropertyGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/MarkdownSnippets/Processing/LinkFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ namespace MarkdownSnippets
public enum LinkFormat
{
GitHub,
Tfs
Tfs,
Bitbucket,
GitLab
}
}
8 changes: 8 additions & 0 deletions src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ string BuildLink(Snippet snippet, string path)
{
return $"{path}&line={snippet.StartLine}&lineEnd={snippet.EndLine}";
}
if (linkFormat == LinkFormat.Bitbucket)
{
return $"{path}#lines={snippet.StartLine}:{snippet.EndLine}";
}
if (linkFormat == LinkFormat.GitLab)
{
return $"{path}#L{snippet.StartLine}-{snippet.EndLine}";
}
#endregion

throw new Exception($"Unknown LinkFormat: {linkFormat}");
Expand Down

0 comments on commit a6e033d

Please sign in to comment.