Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/Elastic.Markdown/Myst/Directives/DirectiveHtmlRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// See the license.txt file in the project root for more information.

using Elastic.Markdown.Diagnostics;
using Elastic.Markdown.Myst.CodeBlocks;
using Elastic.Markdown.Myst.FrontMatter;
using Elastic.Markdown.Myst.Settings;
using Elastic.Markdown.Myst.Substitution;
Expand Down Expand Up @@ -85,11 +84,14 @@ protected override void Write(HtmlRenderer renderer, DirectiveBlock directiveBlo

private void WriteImage(HtmlRenderer renderer, ImageBlock block)
{
var imageUrl =
block.ImageUrl != null &&
(block.ImageUrl.StartsWith("/_static") || block.ImageUrl.StartsWith("_static"))
? $"{block.Build.UrlPathPrefix}/{block.ImageUrl.TrimStart('/')}"
: block.ImageUrl;
var imageUrl = block.ImageUrl;
if (!string.IsNullOrEmpty(block.ImageUrl))
{
if (block.ImageUrl.StartsWith('/') || block.ImageUrl.StartsWith("_static"))
imageUrl = $"{block.Build.UrlPathPrefix}/{block.ImageUrl.TrimStart('/')}";
else
imageUrl = block.Build.UrlPathPrefix + '/' + Path.GetRelativePath(block.Build.ConfigurationPath.DirectoryName!, block.CurrentFile.DirectoryName!) + "/" + block.ImageUrl;
}
var slice = Image.Create(new ImageViewModel
{
Label = block.Label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private static void UpdateLinkUrl(LinkInline link, string url, ParserContext con
private static string GetRootRelativePath(ParserContext context, IFileInfo file)
{
var docsetDirectory = context.Configuration.SourceFile.Directory;
return file.FullName.Replace(docsetDirectory!.FullName, string.Empty);
return "/" + Path.GetRelativePath(docsetDirectory!.FullName, file.FullName);
}

private static bool IsCrossLink([NotNullWhen(true)] Uri? uri) =>
Expand Down