From 35e65e35398c38fe0feb7756692c566fb182e5e4 Mon Sep 17 00:00:00 2001 From: Meghan Stewart <33289333+mestew@users.noreply.github.com> Date: Fri, 27 Mar 2026 08:12:55 -0700 Subject: [PATCH 1/3] add imageUrl to _imageLineRegExes and regex for replacing site relative links --- cleanrepo/Program.cs | 3 ++- cleanrepo/Repo.cs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cleanrepo/Program.cs b/cleanrepo/Program.cs index c05116a0..ce0310d5 100644 --- a/cleanrepo/Program.cs +++ b/cleanrepo/Program.cs @@ -502,7 +502,8 @@ private static void ReplaceLinks(List linkingFiles, string urlBasePath "]*?src[ ]*=[ ]*\"(/" + urlBasePath + "/([^>]*?.(png|gif|jpg|svg)))[ ]*\"", // @"\[.*\]:[ ]*(/" + urlBasePath + @"/(.*\.(png|gif|jpg|svg)))", // [0]: /azure/mydocs/media/pic1.png @"imageSrc:[ ]*(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))", // imageSrc: /azure/mydocs/media/pic1.png - @":::image[^:]*source=""(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))""[^:]*:::" // :::image type="complex" source="/azure/mydocs/media/pic1.png" alt-text="Screenshot."::: + @":::image[^:]*source=""(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))""[^:]*:::", // :::image type="complex" source="/azure/mydocs/media/pic1.png" alt-text="Screenshot."::: + @"imageUrl:[ ]*(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))" // imageUrl: /azure/mydocs/media/pic1.png ]; foreach (FileInfo linkingFile in linkingFiles) diff --git a/cleanrepo/Repo.cs b/cleanrepo/Repo.cs index b027e1df..22e3faff 100644 --- a/cleanrepo/Repo.cs +++ b/cleanrepo/Repo.cs @@ -27,7 +27,8 @@ class DocFxRepo(string startDirectory, string urlBasePath) "lightbox\\s*=\\s*\"(?.*?(\\.(png|gif|jpg|svg))+)\"", // lightbox="media/azure.png" ":::image [^:]*?source\\s*=\\s*\"(?.*?(\\.(png|gif|jpg|svg))+)(\\?[\\w\\s=\\.]+)?\\s*\"", // :::image type="content" source="media/publish.png?text=Publish dialog." alt-text="Publish dialog."::: "[^\"]*?(\\.(png|gif|jpg|svg))+)\"", // - "\\]\\((?[^\\)]*?(\\.(png|jpg|gif|svg)))+(#lightbox)[\\s|\\)]" //](../images/alignment-expansion-large.png#lightbox) + "\\]\\((?[^\\)]*?(\\.(png|jpg|gif|svg)))+(#lightbox)[\\s|\\)]", //](../images/alignment-expansion-large.png#lightbox) + @"imageUrl:(?[^:]*?(\.(png|gif|jpg|svg))+)" // imageUrl: media/microsoft-365-copilot-hub/copilot-hub-work-1.jpg ]; private List? _allMdAndYmlFiles; private List? AllMdAndYmlFiles @@ -218,6 +219,7 @@ internal void OutputImageReferences(bool ocrImages = false, bool filteredOcrImag /// [0]: ../../media/vs-acr-provisioning-dialog-2019.png /// :::image type = "complex" source="./media/seedwork-classes.png" alt-text="Screenshot of the SeedWork folder."::: /// :::image type = "content" source="../media/rpi.png" lightbox="../media/rpi-lightbox.png"::: + /// imageUrl: media/microsoft-365-copilot-hub/copilot-hub-work-1.jpg /// private void CatalogImages() { From eb2866f5eb51699fb92462d11981cf95aba500f5 Mon Sep 17 00:00:00 2001 From: Meghan Stewart <33289333+mestew@users.noreply.github.com> Date: Fri, 27 Mar 2026 08:22:36 -0700 Subject: [PATCH 2/3] add changes to program.cs for site relative --- cleanrepo/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cleanrepo/Program.cs b/cleanrepo/Program.cs index ce0310d5..6f9ad27a 100644 --- a/cleanrepo/Program.cs +++ b/cleanrepo/Program.cs @@ -503,7 +503,7 @@ private static void ReplaceLinks(List linkingFiles, string urlBasePath @"\[.*\]:[ ]*(/" + urlBasePath + @"/(.*\.(png|gif|jpg|svg)))", // [0]: /azure/mydocs/media/pic1.png @"imageSrc:[ ]*(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))", // imageSrc: /azure/mydocs/media/pic1.png @":::image[^:]*source=""(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))""[^:]*:::", // :::image type="complex" source="/azure/mydocs/media/pic1.png" alt-text="Screenshot."::: - @"imageUrl:[ ]*(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))" // imageUrl: /azure/mydocs/media/pic1.png + @"imageUrl:[ ]*(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))" // imageUrl: /azure/mydocs/media/pic1.png ]; foreach (FileInfo linkingFile in linkingFiles) From 88999b67e07a181b52863d62e3062055bdca338c Mon Sep 17 00:00:00 2001 From: Meghan Stewart <33289333+mestew@users.noreply.github.com> Date: Mon, 30 Mar 2026 10:25:00 -0700 Subject: [PATCH 3/3] combine imageSrc and imageUrl into one regex --- cleanrepo/Program.cs | 6 +++--- cleanrepo/Repo.cs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cleanrepo/Program.cs b/cleanrepo/Program.cs index 6f9ad27a..877bd11c 100644 --- a/cleanrepo/Program.cs +++ b/cleanrepo/Program.cs @@ -501,9 +501,9 @@ private static void ReplaceLinks(List linkingFiles, string urlBasePath @"\]:\s(/" + urlBasePath + @"/([^\s]*))", // [ref link]: /basepath/some other text "]*?src[ ]*=[ ]*\"(/" + urlBasePath + "/([^>]*?.(png|gif|jpg|svg)))[ ]*\"", // @"\[.*\]:[ ]*(/" + urlBasePath + @"/(.*\.(png|gif|jpg|svg)))", // [0]: /azure/mydocs/media/pic1.png - @"imageSrc:[ ]*(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))", // imageSrc: /azure/mydocs/media/pic1.png - @":::image[^:]*source=""(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))""[^:]*:::", // :::image type="complex" source="/azure/mydocs/media/pic1.png" alt-text="Screenshot."::: - @"imageUrl:[ ]*(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))" // imageUrl: /azure/mydocs/media/pic1.png + @"image(?:Src|Url):\s*(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))", // imageSrc: /azure/mydocs/media/pic1.png or imageUrl: /azure/mydocs/media/pic1.png + @":::image[^:]*source=""(/" + urlBasePath + @"/([^:]*\.(png|gif|jpg|svg)))""[^:]*:::" // :::image type="complex" source="/azure/mydocs/media/pic1.png" alt-text="Screenshot."::: + ]; foreach (FileInfo linkingFile in linkingFiles) diff --git a/cleanrepo/Repo.cs b/cleanrepo/Repo.cs index 22e3faff..820d012e 100644 --- a/cleanrepo/Repo.cs +++ b/cleanrepo/Repo.cs @@ -22,13 +22,13 @@ class DocFxRepo(string startDirectory, string urlBasePath) @"!\[.*?\]\((?.*?(\.(png|jpg|gif|svg))+)", // ![hello](media/how-to/xamarin.png) "]*?src[ ]*=[ ]*[\"'](?[^>]*?(\\.(png|gif|jpg|svg))+)[ ]*[\"']", // Start icon @"\[.*\]:(?.*?(\.(png|gif|jpg|svg))+)", // [0]: ../../media/how-to/xamarin.png - @"imageSrc:(?[^:]*?(\.(png|gif|jpg|svg))+)", // imageSrc: ./media/vs-mac.svg + @"image(Src|Url):(?[^:]*?(\.(png|gif|jpg|svg))+)", // imageSrc: ./media/vs-mac.svg or imageUrl: ./media/vs-mac.svg @"thumbnailUrl: (?.*?(\.(png|gif|jpg|svg))+)", // thumbnailUrl: /thumbs/two-forest.png "lightbox\\s*=\\s*\"(?.*?(\\.(png|gif|jpg|svg))+)\"", // lightbox="media/azure.png" ":::image [^:]*?source\\s*=\\s*\"(?.*?(\\.(png|gif|jpg|svg))+)(\\?[\\w\\s=\\.]+)?\\s*\"", // :::image type="content" source="media/publish.png?text=Publish dialog." alt-text="Publish dialog."::: "[^\"]*?(\\.(png|gif|jpg|svg))+)\"", // - "\\]\\((?[^\\)]*?(\\.(png|jpg|gif|svg)))+(#lightbox)[\\s|\\)]", //](../images/alignment-expansion-large.png#lightbox) - @"imageUrl:(?[^:]*?(\.(png|gif|jpg|svg))+)" // imageUrl: media/microsoft-365-copilot-hub/copilot-hub-work-1.jpg + "\\]\\((?[^\\)]*?(\\.(png|jpg|gif|svg)))+(#lightbox)[\\s|\\)]" //](../images/alignment-expansion-large.png#lightbox) + ]; private List? _allMdAndYmlFiles; private List? AllMdAndYmlFiles @@ -215,11 +215,11 @@ internal void OutputImageReferences(bool ocrImages = false, bool filteredOcrImag /// ![Architecture] (./media/ci-cd-flask/Architecture.PNG? raw = true) /// The Light Bulb icon ![Small Light Bulb Icon] (media/vs2015_lightbulbsmall.png "VS2017_LightBulbSmall") /// imageSrc: ./media/vs-mac-2019.svg + /// imageUrl: media/microsoft-365-copilot-hub/copilot-hub-work-1.jpg /// Work Backlogs page shortcuts /// [0]: ../../media/vs-acr-provisioning-dialog-2019.png /// :::image type = "complex" source="./media/seedwork-classes.png" alt-text="Screenshot of the SeedWork folder."::: /// :::image type = "content" source="../media/rpi.png" lightbox="../media/rpi-lightbox.png"::: - /// imageUrl: media/microsoft-365-copilot-hub/copilot-hub-work-1.jpg /// private void CatalogImages() {