pull/533/head
Alper Ebicoglu 7 years ago
parent e4e440bc2d
commit a899914ab1

@ -32,7 +32,7 @@ namespace Volo.Docs.Formatting
var normalized = Regex.Replace(content, MarkdownLinkRegExp, delegate (Match match)
{
var displayText = match.Groups[1].Value;
var documentName = RemoveFileExtensionIfLocalUrl(match.Groups[2].Value);
var documentName = RemoveFileExtension(match.Groups[2].Value);
var documentLocalDirectoryNormalized = documentLocalDirectory.TrimStart('/').TrimEnd('/');
if (!string.IsNullOrWhiteSpace(documentLocalDirectoryNormalized))
{
@ -43,22 +43,28 @@ namespace Volo.Docs.Formatting
});
normalized = Regex.Replace(normalized, AnchorLinkRegExp, delegate (Match match)
{
var displayText = match.Groups[2].Value;
var documentName = RemoveFileExtensionIfLocalUrl(match.Groups[1].Value);
var documentLocalDirectoryNormalized = documentLocalDirectory.TrimStart('/').TrimEnd('/');
if (!string.IsNullOrWhiteSpace(documentLocalDirectoryNormalized))
{
documentLocalDirectoryNormalized = "/" + documentLocalDirectoryNormalized;
}
return string.Format(NewLinkFormat, displayText, projectShortName, version, documentLocalDirectoryNormalized, documentName);
});
{
var link = match.Groups[1].Value;
if (IsRemoteUrl(link))
{
return match.Value;
}
var displayText = match.Groups[2].Value;
var documentName = RemoveFileExtension(link);
var documentLocalDirectoryNormalized = documentLocalDirectory.TrimStart('/').TrimEnd('/');
if (!string.IsNullOrWhiteSpace(documentLocalDirectoryNormalized))
{
documentLocalDirectoryNormalized = "/" + documentLocalDirectoryNormalized;
}
return string.Format(NewLinkFormat, displayText, projectShortName, version, documentLocalDirectoryNormalized, documentName);
});
return normalized;
}
private static string RemoveFileExtensionIfLocalUrl(string documentName)
private static string RemoveFileExtension(string documentName)
{
if (documentName == null)
{
@ -75,11 +81,6 @@ namespace Volo.Docs.Formatting
return documentName;
}
if (IsRemoteUrl(documentName))
{
return documentName;
}
return documentName.Left(documentName.Length - Type.Length - 1);
}

Loading…
Cancel
Save