From 38378ead1f9b61e95d1586269f25792df5504c56 Mon Sep 17 00:00:00 2001 From: Valdis Thomann Date: Tue, 26 Mar 2024 00:35:41 +1100 Subject: [PATCH 1/2] Add DevOps link formatting --- readme.md | 10 ++++++++-- src/MarkdownSnippets/Processing/LinkFormat.cs | 1 + .../Processing/SnippetMarkdownHandling.cs | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 3cc75ad7..ba59b7f1 100644 --- a/readme.md +++ b/readme.md @@ -266,10 +266,11 @@ public enum LinkFormat Tfs, Bitbucket, GitLab, + DevOps, None } ``` -snippet source | anchor +snippet source | anchor Link format `None` will omit the source link but still keep the snippet anchor. @@ -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"); +} ``` -snippet source | anchor +snippet source | anchor diff --git a/src/MarkdownSnippets/Processing/LinkFormat.cs b/src/MarkdownSnippets/Processing/LinkFormat.cs index 95b5540a..47843283 100644 --- a/src/MarkdownSnippets/Processing/LinkFormat.cs +++ b/src/MarkdownSnippets/Processing/LinkFormat.cs @@ -6,5 +6,6 @@ public enum LinkFormat Tfs, Bitbucket, GitLab, + DevOps, None } \ No newline at end of file diff --git a/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs b/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs index 357fe8c5..79385825 100644 --- a/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs +++ b/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs @@ -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"); + } + #endregion throw new($"Unknown LinkFormat: {linkFormat}"); From 5b14542ddf52bf7e585b443ba03c585dc4479cc5 Mon Sep 17 00:00:00 2001 From: Valdis Thomann Date: Tue, 26 Mar 2024 00:43:09 +1100 Subject: [PATCH 2/2] Add large lineEndColumn to ensure all of last line is highlighted --- readme.md | 2 +- src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index ba59b7f1..8ee084cd 100644 --- a/readme.md +++ b/readme.md @@ -328,7 +328,7 @@ if (linkFormat == LinkFormat.GitLab) if (linkFormat == LinkFormat.DevOps) { - Polyfill.Append(builder, $"?path={path}&line={snippet.StartLine}&lineEnd={snippet.EndLine}&lineStartColumn=1"); + Polyfill.Append(builder, $"?path={path}&line={snippet.StartLine}&lineEnd={snippet.EndLine}&lineStartColumn=1&lineEndColumn=999"); } ``` snippet source | anchor diff --git a/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs b/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs index 79385825..447ace93 100644 --- a/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs +++ b/src/MarkdownSnippets/Processing/SnippetMarkdownHandling.cs @@ -120,7 +120,7 @@ void BuildLink(Snippet snippet, string path, StringBuilder builder) if (linkFormat == LinkFormat.DevOps) { - Polyfill.Append(builder, $"?path={path}&line={snippet.StartLine}&lineEnd={snippet.EndLine}&lineStartColumn=1"); + Polyfill.Append(builder, $"?path={path}&line={snippet.StartLine}&lineEnd={snippet.EndLine}&lineStartColumn=1&lineEndColumn=999"); } #endregion