Skip to content

Commit

Permalink
Add DevOps formatting (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValdisThomann authored Mar 25, 2024
1 parent e5c0025 commit bbf1ab0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,11 @@ public enum LinkFormat
Tfs,
Bitbucket,
GitLab,
DevOps,
None
}
```
<sup><a href='/src/MarkdownSnippets/Processing/LinkFormat.cs#L1-L10' title='Snippet source file'>snippet source</a> | <a href='#snippet-LinkFormat.cs' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/MarkdownSnippets/Processing/LinkFormat.cs#L1-L11' title='Snippet source file'>snippet source</a> | <a href='#snippet-LinkFormat.cs' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Link format `None` will omit the source link but still keep the snippet anchor.
Expand Down Expand Up @@ -324,8 +325,13 @@ if (linkFormat == LinkFormat.GitLab)
Polyfill.Append(builder, $"{path}#L{snippet.StartLine}-{snippet.EndLine}");
return;
}

if (linkFormat == LinkFormat.DevOps)
{
Polyfill.Append(builder, $"?path={path}&line={snippet.StartLine}&lineEnd={snippet.EndLine}&lineStartColumn=1&lineEndColumn=999");
}
```
<sup><a href='/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs#L96-L120' title='Snippet source file'>snippet source</a> | <a href='#snippet-BuildLink' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs#L96-L126' title='Snippet source file'>snippet source</a> | <a href='#snippet-BuildLink' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
1 change: 1 addition & 0 deletions src/MarkdownSnippets/Processing/LinkFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public enum LinkFormat
Tfs,
Bitbucket,
GitLab,
DevOps,
None
}
6 changes: 6 additions & 0 deletions src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ void BuildLink(Snippet snippet, string path, StringBuilder builder)
Polyfill.Append(builder, $"{path}#L{snippet.StartLine}-{snippet.EndLine}");
return;
}

if (linkFormat == LinkFormat.DevOps)
{
Polyfill.Append(builder, $"?path={path}&line={snippet.StartLine}&lineEnd={snippet.EndLine}&lineStartColumn=1&lineEndColumn=999");
}

#endregion

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

0 comments on commit bbf1ab0

Please sign in to comment.