Skip to content

Commit

Permalink
fix calendar svg converter
Browse files Browse the repository at this point in the history
  • Loading branch information
encse committed Dec 31, 2024
1 parent b3bb623 commit a4b0418
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Lib/Model/Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text.RegularExpressions;
using System.Text;
using AngleSharp.Dom;
using System.Globalization;

namespace AdventOfCode.Model;

Expand Down Expand Up @@ -97,7 +98,7 @@ public static Calendar Parse(int year, IDocument document) {
foreach (var textNode in GetText(calendar)) {
var text = textNode.Text();
var style = textNode.ParentElement.ComputeCurrentStyle();
var rgbaColor = style["color"];
var rgbaColor = !string.IsNullOrEmpty(style["color"]) ? style["color"]: "rgba(204,204,204,1)";
var bold = !string.IsNullOrEmpty(style["text-shadow"]);

if (style["position"] == "absolute" ||
Expand All @@ -111,7 +112,7 @@ public static Calendar Parse(int year, IDocument document) {

var m = Regex.Match(widthSpec, "[.0-9]+");
if (m.Success) {
var width = double.Parse(m.Value) * 1.7;
var width = double.Parse(m.Value, CultureInfo.InvariantCulture) * 1.7;
var c = (int)Math.Round(width - text.Length, MidpointRounding.AwayFromZero);
if (c > 0) {
text += new string(' ', c);
Expand Down

0 comments on commit a4b0418

Please sign in to comment.