generated from cotes2020/chirpy-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
executable file
·46 lines (38 loc) · 1.17 KB
/
Program.cs
File metadata and controls
executable file
·46 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using HtmlAgilityPack;
using System;
using System.IO;
class Program
{
static void Main(string[] args)
{
// Define the path to the HTML file
string filePath = args?.Length > 0 ? args[0] : "/Users/owner/website/team/benjamin-laneave/index.html";
// Check if the file exists
if (!File.Exists(filePath))
{
Console.WriteLine($"The file {filePath} does not exist.");
return;
}
// Read the HTML content from the file
string html = File.ReadAllText(filePath);
HtmlDocument document = new HtmlDocument();
document.LoadHtml(html);
var anchors = document.DocumentNode.SelectNodes("//a[@class='block' or @class='py-6 block']");
foreach (var anchor in anchors)
{
var svgs = anchor.SelectNodes(".//svg");
if (svgs != null)
{
foreach (var svg in svgs)
{
svg.ParentNode.ReplaceChild(HtmlNode.CreateNode("<!-- .site-logo -->"), svg);
}
}
}
// Output the modified HTML
// Console.WriteLine(document.DocumentNode.OuterHtml);
File.WriteAllText(filePath, document.DocumentNode.OuterHtml);
Console.WriteLine($"The file {filePath} does not exist.");
return;
}
}