Skip to content

Commit f1901b7

Browse files
Matteo TrapaniMaxMelcher
Matteo Trapani
authored andcommitted
#119 Fix SVG export
Added specific handling of SVG extension
1 parent ece9193 commit f1901b7

File tree

7 files changed

+65
-3
lines changed

7 files changed

+65
-3
lines changed

AzureDevOps.WikiPDFExport.Test/WikiPDFExporterTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class WikiPDFExporterTests
2020
[InlineData("EmptyOrderFile")]
2121
[InlineData("Flat")]
2222
[InlineData("WellFormed")]
23+
[InlineData("PngSvgExport")]
2324
public async void ExportWiki_IncludeUnlistedPages_Succeeds(string wikiToExport)
2425
{
2526
var options = new Options
@@ -53,6 +54,7 @@ public async void ExportWiki_IncludeUnlistedPages_Succeeds(string wikiToExport)
5354
[InlineData("Flat")]
5455
[InlineData("WellFormed")]
5556
[InlineData("SingleFileNoOrder")]
57+
[InlineData("PngSvgExport")]
5658
public async void ExportWiki_OnlyOrderListedPages_Succeeds(string wikiToExport)
5759
{
5860
var options = new Options

AzureDevOps.WikiPDFExport.Test/test-data/Expected/IncludeUnlistedPages/PngSvgExport.pdf.html

Lines changed: 9 additions & 0 deletions
Large diffs are not rendered by default.

AzureDevOps.WikiPDFExport.Test/test-data/Expected/OrderListedPages/PngSvgExport.pdf.html

Lines changed: 9 additions & 0 deletions
Large diffs are not rendered by default.
Loading
Lines changed: 31 additions & 0 deletions
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Premise
2+
This is a wiki page to test export PNG and SVG
3+
4+
---
5+
6+
# PNG
7+
![test.png](./.attachments/test.png)
8+
9+
---
10+
11+
# SVG
12+
![test.svg](./.attachments/test.svg)

AzureDevOps.WikiPDFExport/MarkdownConverter.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,8 @@ public void CorrectLinksAndImages(MarkdownObject document, MarkdownFile mf)
416416
{
417417
//convert images to base64 and embed them in the html. Chrome/Puppeter does not show local files because of security reasons.
418418
Byte[] bytes = File.ReadAllBytes(fileInfo.FullName);
419-
String base64 = Convert.ToBase64String(bytes);
420-
421-
link.Url = $"data:image/{fileInfo.Extension};base64,{base64}";
419+
var base64 = Convert.ToBase64String(bytes);
420+
link.Url = $"data:image/{(fileInfo.Extension == ".svg" ? "svg+xml" : fileInfo.Extension)};base64,{base64}";
422421
}
423422

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

0 commit comments

Comments
 (0)