|
3 | 3 | // See the LICENSE file in the project root for more information
|
4 | 4 |
|
5 | 5 | using System.IO.Abstractions;
|
| 6 | +using System.Runtime.InteropServices; |
6 | 7 | using System.Text.RegularExpressions;
|
7 | 8 | using Elastic.Markdown.IO;
|
8 | 9 | using Microsoft.Extensions.Logging;
|
@@ -64,6 +65,9 @@ private async Task SetupChanges(ChangeSet changeSet, Cancel ctx)
|
64 | 65 | var fullPath = Path.GetFullPath(Path.Combine(sourceDirectory, originalPath));
|
65 | 66 | var relativePath = Path.GetRelativePath(targetDirectory, fullPath);
|
66 | 67 |
|
| 68 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
| 69 | + relativePath = relativePath.Replace('\\', '/'); |
| 70 | + |
67 | 71 | newPath = originalPath.StartsWith("./", OrdinalIgnoreCase) && !relativePath.StartsWith("./", OrdinalIgnoreCase)
|
68 | 72 | ? "./" + relativePath
|
69 | 73 | : relativePath;
|
@@ -258,6 +262,15 @@ string targetPath
|
258 | 262 | var absolutStyleSource = $"/{relativeToDocsFolder}";
|
259 | 263 | var relativeToDocsFolderTarget = Path.GetRelativePath(documentationSet.SourceDirectory.FullName, targetPath);
|
260 | 264 | var absoluteStyleTarget = $"/{relativeToDocsFolderTarget}";
|
| 265 | + |
| 266 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
| 267 | + { |
| 268 | + relativeSource = relativeSource.Replace('\\', '/'); |
| 269 | + relativeSourceWithDotSlash = relativeSourceWithDotSlash.Replace('\\', '/'); |
| 270 | + absolutStyleSource = absolutStyleSource.Replace('\\', '/'); |
| 271 | + absoluteStyleTarget = absoluteStyleTarget.Replace('\\', '/'); |
| 272 | + } |
| 273 | + |
261 | 274 | return (
|
262 | 275 | relativeSource,
|
263 | 276 | relativeSourceWithDotSlash,
|
@@ -298,6 +311,9 @@ private string ReplaceLinks(
|
298 | 311 | : $"[{match.Groups[1].Value}]({relativeTarget}{anchor})";
|
299 | 312 | }
|
300 | 313 |
|
| 314 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
| 315 | + newLink = newLink.Replace('\\', '/'); |
| 316 | + |
301 | 317 | var lineNumber = content[..match.Index].Count(c => c == '\n') + 1;
|
302 | 318 | var columnNumber = match.Index - content.LastIndexOf('\n', match.Index);
|
303 | 319 | if (!_linkModifications.ContainsKey(changeSet))
|
|
0 commit comments