Skip to content

Commit

Permalink
Updated expected result.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmester committed Jul 17, 2021
1 parent c19ef18 commit 44b64cc
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/PdfToSvg.Tests/ConversionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ private static string RecompressPngs(string svgMarkup)
.Descendants(ns + "use")
.ToLookup(el => el.Attribute("href").Value);

var maskReferences = svg
.Descendants(ns + "g")
.ToLookup(el => el.Attribute("mask")?.Value);

foreach (var image in svg.Descendants(ns + "image"))
{
var hrefAttribute = image.Attribute("href");
Expand All @@ -165,6 +169,19 @@ private static string RecompressPngs(string svgMarkup)
foreach (var reference in useElements["#" + oldId])
{
reference.SetAttributeValue("href", "#" + newId);

if (reference.Parent.Name.LocalName == "mask")
{
var newMaskId = StableID.Generate("m", newId);
var oldMaskId = reference.Parent.Attribute("id").Value;

reference.Parent.SetAttributeValue("id", newMaskId);

foreach (var maskReference in maskReferences["url(#" + oldMaskId + ")"])
{
maskReference.SetAttributeValue("mask", "url(#" + newMaskId + ")");
}
}
}
}
}
Expand Down
Loading

0 comments on commit 44b64cc

Please sign in to comment.