@KekunPlazas +9001%
I find #Gemini to be worse than #HTML5 + #CSS3 or just bland #Markdown...
@KekunPlazas +9001%
I find #Gemini to be worse than #HTML5 + #CSS3 or just bland #Markdown...
Spent today making #HTML5 visuals: Rolling hills, falling blocks, galaxy, matrix and more. Take a look at this short preview:
My version of a Pilot Logbook application reached alpha status.
It stores the minimum data required by the German NfL 2212-21, plus some data recorded in my paper log. And some data I deem interesting, like engine time and fuel consumption.
I even managed to hack together a CSV parser (no native support in Javascript ), so that the program can import data from Vereinsflieger (fleet management web app of my club).
Friday 13th? Perfect time to start the countdown to #js13k 2025! The fourteenth edition of the yearly web game development competition will begin two months from now, on August 13th!
@ciourte @netopwibby Needless to say I've only heard of some Spanish low-cost #MVNO offering one device only in a #prepaid #bundle when #FirefoxOS was unveiled at the #MWC in #Barcelona based off coverage in @ct_Magazin at the time.
Alas @Mozilla deciding on purpose to literally splinter the market by letting #MNO|s and MVNOs run their #AppStore|s instead of a #centralized model, making the situation worse than in the "P.R." #China where there are several vendor-independent #AppStores for #Android.
Still, I'm #StillMad at #Mozilla for faceplanting Firefox OS cuz it had the easiest way to get started and a good architecture being every #App is just a #WebApp and all the system calls were standard #HTML5 permissions and nothing fancy.
some design stuff happened. i linked a manifest file. i have no idea what i’m doing.
#1bit #1bitart #solodev #developers #oc #gamedev #lowres #ditherpunk #doodle #rasterpunk #60Grid #javascript #webdev #webapp #mobiledev #html5
Posting in case this helps someone else.
For the last month or two, I've had problems visiting some sites with #Firefox. The sites use #Cloudflare, and it would give the "prove you're a human by checking this box" prompt. I'd never had problems with this before.
Suddenly that started failing consistently. Clicking the box would do something, but then just reload the challenge. There was no way to pass it. I tried reconfiguring and even disabling the "uBlock Origin" extension, cookie policies, other things - no luck.
Based on a comment on this discussion:
https://ask.metafilter.com/385480/fixing-Verify-You-Are-A-Human-Firefox-cookies-UBlock-Origin
... I tried disabling the "Disable HTML5 Autoplay" extension, and ... fixed! That was *not* an obvious candidate for causing the problem, unlike adblockers etc.
So it appears Cloudflare changed their in-browser testing JS such that it requires HTML5 autoplay to pass the check. Which is ... special. I can think of lots of people with very good reasons to have that disabled.
Anyways, I hope this helps someone.
Stop using preg_* on HTML and start using \Dom\HTMLDocument instead
https://shkspr.mobi/blog/2025/05/stop-using-preg_-on-html-and-use-domhtmldocument/
It is a truth universally acknowledged that a programmer in possession of some HTML will eventually try to parse it with a regular expression.
This makes many people very angry and is widely regarded as a bad move.
In the bad old days, it was somewhat understandable for a PHP coder to run a quick-and-dirty preg_replace()
on a scrap of code. They probably could control the input and there wasn't a great way to manipulate an HTML5 DOM.
Rejoice sinners! PHP 8.4 is here to save your wicked souls. There's a new HTML5 Parser which makes everything better and stops you having to write brittle regexen.
Here are a few tips - mostly notes to myself - but I hope you'll find useful.
Sanitise HTML
This is the most basic example. This loads HTML into a DOM, tries to fix all the mistakes it finds, and then spits out the result.
PHP$html = '<p id="yes" id="no"><em>Hi</div><h2>Test</h3><img />';$dom = \Dom\HTMLDocument::createFromString( $html, LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED , "UTF-8" );echo $dom->saveHTML();
It uses LIBXML_HTML_NOIMPLIED
because we don't want a full HTML document with a doctype, head, body, etc.
If you want Pretty Printing, you can use my library.
Get the plain text
OK, so you've got the DOM, how do you get the text of the body without any of the surrounding HTML
PHP$html = '<p><em>Hello</em> World!</p>';$dom = \Dom\HTMLDocument::createFromString( $html, LIBXML_NOERROR , "UTF-8" );echo $dom->body->textContent;
Note, this doesn't replace images with their alt text.
Get a single element
You can use the same querySelector()
function as you do in JavaScript!
PHP$element = $dom->querySelector( "h2" );
That returns a pointer to the element. Which means you can run:
PHP$element->setAttribute( "id", "interesting" );echo $dom->querySelector( "h2" )->attributes["id"]->value;
And you will see that the DOM has been manipulated!
Search for multiple elements
Suppose you have a bunch of headings and you want to get all of them. You can use the same querySelectorAll()
function as you do in JavaScript!
To get all headings, in the order they appear:
PHP$headings = $dom->querySelectorAll( "h1, h2, h3, h4, h5, h6" );foreach ( $headings as $heading ) { // Do something}
Advanced Search
Suppose you have a bunch of links and you want to find only those which point to "example.com/test/". Again, you can use the same attribute selectors as you would elsewhere
PHP$dom->querySelectorAll( "a[href^=https\:\/\/example\.com\/test\/]" );
Replacing content
Sadly, it isn't quite as simple as setting the innerHTML
. Each search returns a node. That node may have children. Those children will also be node which, themselves, may have children, and so on.
Let's take a simple example:
PHP$html = '<h2>Hello</h2>';$dom = \Dom\HTMLDocument::createFromString( $html, LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED, "UTF-8" );$element = $dom->querySelector( "h2" );$element->childNodes[0]->textContent = "Goodbye";echo $dom->saveHTML();
That changes "Hello" to "Goodbye".
But what if the element has child nodes?
PHP$html = '<h2>Hello <em>friend</em></h2>';$dom = \Dom\HTMLDocument::createFromString( $html, LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED, "UTF-8" );$element = $dom->querySelector( "h2" );$element->childNodes[0]->textContent = "Goodbye";echo $dom->saveHTML();
That outputs <h2>Goodbye<em>friend</em></h2>
- so think carefully about the structure of the DOM and what you want to replace.
Adding a new node
This one is tricky! Let's suppose you have this:
HTML<div id="page"> <main> <h2>Hello</h2>
You want to add an <h1>
before the <h2>
. Here's how to do this.
First, you need to construct the DOM:
PHP$html = '<div id="page"><main><h2>Hello</h2>';$dom = \Dom\HTMLDocument::createFromString( $html, LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED, "UTF-8" );
Next, you need to construct an entirely new DOM for your new node.
PHP$newHTML = "<h1>Title</h1>";$newDom = \Dom\HTMLDocument::createFromString( $newHTML, LIBXML_NOERROR | LIBXML_HTML_NOIMPLIED, "UTF-8" );
Next, extract the new element from the new DOM, and import it into the original DOM:
PHP$element = $dom->importNode( $newDom->firstChild, true );
The element now needs to be inserted somewhere in the original DOM. In this case, get the h2
, tell its parent node to insert the new node before the h2
:
PHP$h2 = $dom->querySelector( "h2" );$h2->parentNode->insertBefore( $element, $h2 );echo $dom->saveHTML();
Out pops:
HTML<div id="page"> <main> <h1>Title</h1> <h2>Hello</h2> </main></div>
An alternative is to use the appendChild()
method. Note that it appends it to the end of the children. For example:
PHP$div = $dom->querySelector( "#page" );$div->appendChild( $element );echo $dom->saveHTML();
Produces:
HTML<div id="page"> <main> <h2>Hello</h2> </main> <h1>Title</h1></div>
And more?
I've only scratched the surface of what the new 8.4 HTML Parser can do. I've already rewritten lots of my yucky old preg_
code to something which (hopefully) is less likely to break in catastrophic ways.
If you have any other tips, please leave a comment.
This will be a short #EnclaveGames #MonthlyReport as it's still all about the ongoing @GamedevJS Jam 2025.
Found this relic today while cleaning. Anyone need some reading on HTML5 and CSS?
Defold: cross-platform game engine
https://defold.com
#ycombinator #defold #gameengine #game_engine #game_development #game_dev #gamedev #open_source #opensource #crossplatform #cross_platform #free #nintendo_switch #console #html5 #web #android #ios #desktop
Free high-performance cross-platform game engine
https://defold.com
#ycombinator #defold #gameengine #game_engine #game_development #game_dev #gamedev #open_source #opensource #crossplatform #cross_platform #free #nintendo_switch #console #html5 #web #android #ios #desktop
Show HN: Corral – A Visual Logic Puzzle About Enclosing Numbers
https://mohammed321.github.io/projects/corral_web/index.html
#ycombinator #programming #examples #html5 #C #library #learn #games #videogames
@ajsadauskas @JessTheUnstill @tomiahonen yes, and to add insult to injury #Mozilla didn't even wanted to sell people like @fuchsiii or me a #FirefoxOS device, with the only one being "launched" in the #EU being a #SimLock'd & #NetLock'd #prepaid phone in #Spain one could only attain in-store with all the "#KYC" nonsense they had, demanding a legal address in Spain back then.
And #nerds like myself are far from the "#consoomer #Normies" for whom stuff that isn't on shelves at Staturn/MediaMarkt, BestBuy, Walmart, ... doesn't exist. I'm used to importing #tech that I want!
DOOM: The Gallery Experience lets you take part in an art gallery opening with a wine in your hand all while wandering through the Doom’s E1M1 map full of classic masterpieces.
https://gamedevjs.com/games/doom-the-gallery-experience-paintings-showcase-simulator/
Use Your RTL, In The Browser - The web browser started life as a relatively simple hypertext reading application,... - https://hackaday.com/2024/12/13/use-your-rtl-in-the-browser/ #software-definedradio #radiohacks #rtl-sdr #html5
@Linux @breadcat @tertle950 the Problem ain't web standards, far from it!
The only issue I can see are assholes blocking Tor and that is IMHO illegal and beeds to be penalized...