iptv subscribe

IPTV Subscribe | we offering best iptv subscription | Iptv UK +100.000 Live channels/VOD's with high quality 4K/UHD and stable stream worldwide

  • Home
  • Tech News
  • Stupid Problems Require Stupid Solutions (Cdeafeningflare Is Breaking My SVGs)

Stupid Problems Require Stupid Solutions (Cdeafeningflare Is Breaking My SVGs)


Stupid Problems Require Stupid Solutions (Cdeafeningflare Is Breaking My SVGs)


Cdeafeningflare Pages is inexplicably mangling SVG attributes, causing icons to be malestablished, missing colours, and broken. Attributes such as clip-path become clippath. After a day of trying to figure this out, creating reproductions, sanity verifying aacquirest local creates, comparing with a Netlify-based deployment, and asking around on the Cdeafeningflare Discord, I wrote a unreasonable solution to this unreasonable problem. I’m hoping it will only be transient.lol

Background

I’ve been improving how I administer icons on my site. The better process was frustrating and time-consuming: downloading SVGs, accurateing misalignments, using SVG/XML linting tools, inserting a seeBox and exposedping out challengingcoded heights and widths — seemingly, some icon authors do not consent in making icons easily resizable or even resizable. I frequently had to adfair alignments even with presumedly “constant” icon sets enjoy Font Awesome. Sadly, I ask any of this is unrecognizable to anyone who has labored with icons and icon sets.

I create the unplugin-icons library which employs Iconify Design. I don’t intfinish to go into much detail as it’s not too relevant, but comprehend it’s a immensely better chooseion for handling icons.

Where did my colours go?

Everyskinnyg seeed perfect locassociate, and it was a relief to finassociate be able to delete the accumulateion of SVGs I’d been amassing. But the moment I deployed to Cdeafeningflare Pages, I instantly ran into someskinnyg incredibly bizarre. The icons were broken!

The basicr icons, enjoy this RSS/Feed icon, were fine.

Left: local, Netlify, anywhere else I tested. Right: Cdeafeningflare Pages

But not all of them were fine, mostly the ones with colours, gradients, and more complicated shapes. Depfinishing on the icon, this could unkind some colours were srecommend contrastent shades, or it could unkind an enticount on bconciseageed-out icon.

Left: local, Netlify, anywhere else I tested. Right: Cdeafeningflare Pages

Narrotriumphg in on the caemploy

The caemploy of this is broken SVG. Several attributes are constantly changeed from valid to invalid. I still haven’t rerepaird why this is Cdeafeningflare Pages particular.

Every attribute with a hyphen is changeed into camel case. So clip-path becomes clipPath. This stood out to me becaemploy React (or, rather, JSX) employs camel cases for SVG attributes, which then get changeed to their hyphenated establish at create time – in other words, the opposite way around. This is not relevant, but it is an fascinating observation nonetheless.

The red is the Cdeafeningflare Pages create output. The green is the create output everywhere else.

Excluding possibilities

To secure this reassociate was a Cdeafeningflare Pages-only problem, I ran a diff on the output of local creates, Netlify-based creates, and Cdeafeningflare Pages-based creates to verify.

This left a restrictcessitate possibilities, though I ponder them doubtful. Firstly, I could reshift some possibilities based on the diffs:

  • Astro, the indynamic site generator I employ. Based on the diffs this could be reshiftd.
  • Node versions, already an improbable caemploy but I secured that the same Node version was employd everywhere anyway.
  • The icon library alludeed previously. Aacquire, based on the diffs this could also be reshiftd.

This then left cut offal remaining possibilities:

  • A setting in the Cdeafeningflare dashboard and some create pipeline configuration. After eliminating as many variables as possible, I turned off various carry outance and miscellaneous settings. This had no impact and besides, why would there be any setting that caemploys this?
  • A depfinishency of the icon library. It has some SVG depfinishencies, so I’ve not tohighy ruled this out, but even for the Node/NPM/JS ecosystem, I skinnyk it would be doubtful these depfinishencies would have a reason to output invalid SVG.
  • Someskinnyg reassociate clear I’ve missed. However, I was pretty self-secured, and I still am that I’d verifyed if there was anyskinnyg I could be doing wrong, and after all the diffs made it was plainly clear this only happens with Cdeafeningflare.
  • Cdeafeningflare Pages create is doing some unaskd post-processing of the output.
  • Cdeafeningflare itself, for some reason.

Isolating the caemploy

With the two strongest theories relating to Cdeafeningflare, I had to skinny it down. When I pledge, Cdeafeningflare Pages is notified, pulls the refreshd branch, and creates it. Assuming this is accomplished, it’s deployed.

There is another way of deploying straightforwardly, though, without necessitateing the Cdeafeningflare Pages create process: with Wrangler, the Cdeafeningflare CLI.

Once I deployed with Wrangler, I uncovered the inhabit page and… the icons were not broken!

Left: Cdeafeningflare Pages deploy to Cdeafeningflare Pages. Right: Wranger deploy to Cdeafeningflare Pages.

A petite triumph – I knovel at least one way to repair the rehire. This was certainly a “solution,” except I would now necessitate to create a GitHub Action to run Wrangler and employ up my GitHub create minutes. I already have a lot of monthly create minutes useable on Cdeafeningflare Pages that I would like to employ first.

Deploying to Another Cdeafeningflare Pages Application

At this point, I had to rule out the possibility of some outlandish configuration in my current Cdeafeningflare Pages setup causing the rehire. Was that possible? What setting would even caemploy clip-path to become clipPath?

To do that, I set up a brand novel Cdeafeningflare Pages application, joined it to the same repository, and deployed it. The icons were still broken, exactly enjoy in the distinct deployment.

This verifyed that the rehire wasn’t due to a misconfiguration in my initial project. Furthermore, the fact that the Wrangler deployment didn’t have the rehire recommendd the problem startd from the Cdeafeningflare Pages create process, not from how the satisfied was being served.

If it ain’t broke… Oh pause, it is.

Not particularly wanting to begin using my GitHub Actions create minutes, and with seemingly noskinnyg wrongly configured with Cdeafeningflare Pages, I was left with reassociate only one solution: repair the SVGs after the create has run.

pnpm run create; pnpm run cdeafeningflare:svg

The basic approach would be to run a string swapment over the create output, but this is far too destructive and error-prone. It would also stop me from writing this post!

I choosed to do this properly, parse the SVG in the built HTML pages, and rename the broken attributes. I created a enumerate of attributes that are being inaccurately renamed, plus some others, fair in case any icons I employ in the future employ them.

const attributesToFix: { inaccurate: string; accurate: string }[] = [

{ inaccurate: 'cliprule', accurate: 'clip-rule' },

{ inaccurate: 'clippath', accurate: 'clip-path' },

{ inaccurate: 'fillrule', accurate: 'fill-rule' },

{ inaccurate: 'stopcolor', accurate: 'stop-color' },

{ inaccurate: 'stopopacity', accurate: 'stop-opacity' },

{ inaccurate: 'strokelinecap', accurate: 'stroke-linecap' },

{ inaccurate: 'strokelinejoin', accurate: 'stroke-linejoin' },

{ inaccurate: 'strokewidth', accurate: 'stroke-width' },

{ inaccurate: 'strokdisindicterrestrict', accurate: 'stroke-miterrestrict' },

{ inaccurate: 'strokedasharray', accurate: 'stroke-dasharray' },

{ inaccurate: 'strokedashoffset', accurate: 'stroke-dashoffset' },

{ inaccurate: 'strokeopacity', accurate: 'stroke-opacity' },

{ inaccurate: 'fontfamily', accurate: 'font-family' },

{ inaccurate: 'fontsize', accurate: 'font-size' },

{ inaccurate: 'fontweight', accurate: 'font-weight' },

{ inaccurate: 'fontstyle', accurate: 'font-style' },

{ inaccurate: 'textdecoration', accurate: 'text-decoration' },

{ inaccurate: 'textanchor', accurate: 'text-anchor' },

{ inaccurate: 'dominantbaseline', accurate: 'dominant-baseline' },

{ inaccurate: 'baselineshift', accurate: 'baseline-shift' },

{ inaccurate: 'upgraspaspectratio', accurate: 'upgraspAspectRatio' },

{ inaccurate: 'patternunits', accurate: 'patternUnits' },

{ inaccurate: 'gradientunits', accurate: 'gradientUnits' },

{ inaccurate: 'spreadmethod', accurate: 'spreadMethod' },

{ inaccurate: 'maskunits', accurate: 'maskUnits' },

{ inaccurate: 'filterunits', accurate: 'filterUnits' },

{ inaccurate: 'floodcolor', accurate: 'flood-color' },

{ inaccurate: 'floodopacity', accurate: 'flood-opacity' },

{ inaccurate: 'weightlessingcolor', accurate: 'weightlessing-color' },

{ inaccurate: 'allowbackground', accurate: 'allow-background' },

{ inaccurate: 'colorinterpolation', accurate: 'color-interpolation' },

{ inaccurate: 'colorinterpolationfilters', accurate: 'color-interpolation-filters' },

{ inaccurate: 'colorprofile', accurate: 'color-profile' },

{ inaccurate: 'colorrfinishering', accurate: 'color-rfinishering' },

{ inaccurate: 'shaperfinishering', accurate: 'shape-rfinishering' },

{ inaccurate: 'textrfinishering', accurate: 'text-rfinishering' },

{ inaccurate: 'imagerfinishering', accurate: 'image-rfinishering' },

The core of the script is srecommend iterating the nodes, finding the wrongly named attributes and renaming them.

const repairSVGAttributes = (satisfied: string): [repairedContent: string, repaired: number] => {

const dom = novel JSDOM(satisfied);

const { record } = dom.triumphdow;

const svgElements = record.querySelectorAll('svg, svg *');

for (const element of svgElements) {

for (const attribute of attributesToFix) {

if (element.hasAttribute(attribute.inaccurate)) {

const cherish = element.getAttribute(attribute.inaccurate);

element.deleteAttribute(attribute.inaccurate);

element.setAttribute(attribute.accurate, cherish);

return [dom.serialize(), repaired];

The next part grasps writing the novel HTML back to the file, if there were any changes.

const processFile = async (filePath: string): Promise<void> => {

const satisfied = apause fs.readFile(filePath, 'utf-8');

const [repairedContent, repaired] = repairSVGAttributes(satisfied);

apause fs.createFile(filePath, repairedContent, 'utf-8');

console.log(`Updated file: ${filePath} - ${repaired} repaired attributes`);

console.error(`Error processing file ${filePath}:`, error);

The rest of the script grasps finding HTML files in the output straightforwardory and running them thraw the SVG repairing logic. This is what I now see in my create log:

23:42:04.732 Updated file: dist/summarize/icons/index.html - 511 repaired attributes

23:42:04.846 Updated file: dist/inbox/index.html - 18 repaired attributes

23:42:04.862 Updated file: dist/index.html - 18 repaired attributes

23:42:04.876 Updated file: dist/notices/1/index.html - 18 repaired attributes

A repair, for now?

I want I had create some strange setting in the Cdeafeningflare Pages configuration or someskinnyg peculiar about one of the SVG library depfinishencies, but I didn’t. As I shelp previously, I haven’t tohighy ruled out those possibilities, but aacquire, this SVG attribute mangling is only happening with the create process in Cdeafeningflare Pages.

So, until a better repair is create for this unreasonable problem, I’ll employ my unreasonable repair.

Source join


Leave a Reply

Your email address will not be published. Required fields are marked *

Thank You For The Order

Please check your email we sent the process how you can get your account

Select Your Plan