Skip to content

Commit

Permalink
#27: Add Image support to Markdown class
Browse files Browse the repository at this point in the history
A new `Image` class is added inside the `Markdown` class, within the `Documentation` project. This class facilitates incorporating images in markdown files, handling file paths and providing a way to specify alternate text for an image. Also, it allows to specify the image path relative to a specific file.
  • Loading branch information
MarcinCelej committed Dec 20, 2023
1 parent 3bec3b3 commit 6db02db
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,13 @@
) : void
- ToString() : string

## Markup.Markdown+Image (class) : Markdown+IElement
- ctor(
filePath: CodeFile,
alternateText: string? [Nullable, Optional]
)
- RelativeTo(
file: CodeFile
) : Markdown+Image
- ToString() : string

22 changes: 22 additions & 0 deletions Documentation/Synergy.Documentation/Markup/Markdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,27 @@ public override string ToString()
}

#endregion

#region Image

public class Image : IElement
{
private readonly CodeFile _filePath;
private readonly string _alternateText;

public Image(CodeFile filePath, string? alternateText = null)
{
_filePath = filePath;
_alternateText = alternateText ?? filePath.FileName;
}

public override string ToString()
=> $"![{_alternateText}]({_filePath.ToString().Replace(" ", "%20")}){Markdown.NL}";

public Image RelativeTo(CodeFile file)
=> new(_filePath.RelativeTo(file.Folder), _alternateText);
}

#endregion
}
}

0 comments on commit 6db02db

Please sign in to comment.