Skip to content

Commit

Permalink
#119 Fix SVG export
Browse files Browse the repository at this point in the history
Added specific handling of SVG extension
  • Loading branch information
Matteo Trapani authored and MaxMelcher committed Feb 26, 2023
1 parent ece9193 commit f1901b7
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 3 deletions.
2 changes: 2 additions & 0 deletions AzureDevOps.WikiPDFExport.Test/WikiPDFExporterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class WikiPDFExporterTests
[InlineData("EmptyOrderFile")]
[InlineData("Flat")]
[InlineData("WellFormed")]
[InlineData("PngSvgExport")]
public async void ExportWiki_IncludeUnlistedPages_Succeeds(string wikiToExport)
{
var options = new Options
Expand Down Expand Up @@ -53,6 +54,7 @@ public async void ExportWiki_IncludeUnlistedPages_Succeeds(string wikiToExport)
[InlineData("Flat")]
[InlineData("WellFormed")]
[InlineData("SingleFileNoOrder")]
[InlineData("PngSvgExport")]
public async void ExportWiki_OnlyOrderListedPages_Succeeds(string wikiToExport)
{
var options = new Options
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Premise
This is a wiki page to test export PNG and SVG

---

# PNG
![test.png](./.attachments/test.png)

---

# SVG
![test.svg](./.attachments/test.svg)
5 changes: 2 additions & 3 deletions AzureDevOps.WikiPDFExport/MarkdownConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,8 @@ public void CorrectLinksAndImages(MarkdownObject document, MarkdownFile mf)
{
//convert images to base64 and embed them in the html. Chrome/Puppeter does not show local files because of security reasons.
Byte[] bytes = File.ReadAllBytes(fileInfo.FullName);
String base64 = Convert.ToBase64String(bytes);

link.Url = $"data:image/{fileInfo.Extension};base64,{base64}";
var base64 = Convert.ToBase64String(bytes);
link.Url = $"data:image/{(fileInfo.Extension == ".svg" ? "svg+xml" : fileInfo.Extension)};base64,{base64}";
}

fileInfo = new FileInfo($"{absPath}.md");
Expand Down

0 comments on commit f1901b7

Please sign in to comment.