544 points · by MH15 · 5y ago · 193 comments
It can't screen record an animation though, but it could be a baseline for hand-animating the elements. Accepting PRs for screen recording functionality :D
https://gist.githubusercontent.com/alphapapa/65b0b9d4b3f5534...
https://github.com/TomasHubelbauer/SVG-Screencast
This is for screen recordings. SVG animations as the OP I play around with, too:
https://github.com/TomasHubelbauer/SVG-3D
:)
[1] https://support.mozilla.org/en-US/kb/add-on-signing-in-firef...
(Here's the Chrome extension link for anyone who's interested: https://chrome.google.com/webstore/detail/svg-screenshot/nfa...)
Source: I am lazy.
I'd love a tool like this for generating animated SVG clips of a web page, it'd help immensely when creating walkthroughs. Video recordings do work, but it's a mess working with different encodings to make it look ok. Not to mention, with SVG such walkthroughs could actually be made interactive...
Would be super helpful to have some example screenshots linked in the readme though, to help set expectations.
The tests take a PNG screenshot of the webpage, then a PNG screenshot of the created SVG and pixelmatch the two. The difference must be below 0.5% for tests to pass.
Yes, you can: https://stackoverflow.com/questions/5378559/including-javasc...
brb as I write a follow up article.
Yes they use Camo, but that's a proxy to ensure that you don't serve JS from the same domain as github.com so that 3rd party assets have the JavaScript domain security policy applied.
I do not believe that Camo is a sanitising proxy... just a proxy.
Seriously, can we stop inventing formats that execute arbitrary code under the hood?
[a]: Embedding the SVG directly into the HTML and manipulating it using the JavaScript in the HTML is an option, but not many people do that
[b]: We can argue all we want about whether we should be making interactive images in the first place, but the fact of the matter is, either you add it to your format, or someone else will
Edit: I think I narrowed down where you were wrong! Github "raw" endpoints for repository files DOES have a sanitizing option. But that's not Camo (camo is for remote, non repo, assets (linked in comments or in markdown)).
But as a consequence now we (still) have no easily portable vector format :'(
SVGs aren't image data. They're a set of instructions for recreating image data using a structured language. XML is very good for data like that.
If you open the SVG file directly, then JavaScript will be executed. But any hosting platforms that hosts your content on their domain should filter out any JavaScript on SVG as it would on HTML.
That's definitely not a thing that happens. Web servers just serve the file as-is.
FYI millions of readmes have had SVG badges for years.
For example, you could post one of those SVGs in every issue thread of a GitHub project if you wanted to mess with someone.
Not eligible for a bug bounty though since this issue has been known (but not fixed) for years.
For example, what happens when you right-click "View image" on an svg file? Does embedded JS get run in that case?
They basically wanted everything that Flash had.
Would be interesting to try to find a hole in this.
This is a hack to be able to embed design within a tool that was never meant for graphic design. If github readmes where meant to be both accessible and designable they would not be just markdown/rst.
Your suggestion means a11y software having a hack that goes against the spec to enable a hack that was used to circumvent a platform that knowingly crippled it's document representation because they thought it would be used for mostly unstyled info.
It's almost 2021. Accessibility software can use ML and OCR to provide a semblance of navigable semantics for visual-first media like images. See Project Naptha [1] for one such example of adding OCR-powered text detection to images encountered in your browser.
In the specific case of SVG, the text can already be fully semantically extracted with very little work.
1) New technology exists
2) Accessibility nerds tell everyone not to use it, because it's not supported by screen readers
3) Everyone uses it anyways
4) Screen readers support it
5) GOTO 1
It seems very similar to people who think they can fix climate change by yelling at enough people not to buy certain things.
Edit: To clarify, I'd love to see SVGs become more accessible, but I would hope the lack of support today isn't a problem as far as README shields.
I think we need to embed accessibility and accessibility audits as a basic and essential aspect of all tooling and standards. It shouldn't be up to diligent people like yourself to notice these issues as a matter of expertise or personal interest, but something we notice by default because it hasn't complied with standards.
SVGs are a minefield for accessibility and tend to be either wrapped in a container with accessibility info or have nothing at all added. It's a mess.
I believe the sandbox attribute would also block javascript / scripts, although not sure what cross browser support on that looks like.
Maybe for special cases, where the content is from the same domain or is actively messaging the size outwards so you can code some interplay between the outer page and the iframe. But neither side can do it alone.
1. Use of AIRA tags on the <img> like `aria-label`
2. `aria-labelled-by` pointing to a <desc> within the SVG?
3. Using the <title> element within the SVG
4. Adding role="group" to make the SVG traversable
5. role attributes on each <g>roup.
JAWS and NVDA will announce this.
I then used svg animation, but still seems to work perfectly today !
However, when I do come across it being used well, it'll be neat!
I have to say though, the developer (sindresorhus) is got to be one of the most prolific NPM package maintainers of all time, they have hundreds (if not thousands) of actively maintained packages. I know a lot of them are single use modules, but still, thats quite something! And the quality isn't bad.
Where does one find the time!
<embed src="scripted-svg.svg" type="image/svg+xml" width="200" height="200">
I couldn't get it working with README.md, so tipping the hat to the author!
The only problem and with the experience I got trying using it, is that the concept of viewport is botched. I was hoping that the embedded JS would have working metrics for the viewed width/height, which it does not.
That means that mouse events and such have transformed coordinates, not matching the position of the cursor.
I have this small project demonstrating the ways embedded JS gets rendered. I think I'm going to revise it and see if both projects can be merged.
Embed is basically like using iframe, so where one is blocked, the other one is too.
The author simply loaded the SVG via the image tag, which renders it inert.
Nice try, but you would not get any fund from those users who already use Links2 or Lynx![0] ;P
$ links2 -g https://github.com/sindresorhus/css-in-readme-like-wat
Only those users who use "modern browsers" or at least Netsurf/Hv3/Dillo/Browsh still may support you.[1,2,3][0] https://news.ycombinator.com/item?id=16191843
[1] https://www.informit.com/articles/article.aspx?p=600978&seqN...
[2] http://www.kompx.com/en/lightweight-web-browsers-for-linux.h...
[3] https://www.hanselman.com/blog/lynx-is-dead-long-live-browsh...
Since I could "borrow" the CSS actually used on GitHub, it was possible to make the images look like a natural part of the real UI.
Given the number of Github projects that want terminal "demonstrations", I'm surprised Github hasn't just provided first-party support for it (with e.g. a fancy renderer for script(1) code-embeds, that would play back the script session by writing regular DOM text nodes; and which would give you transport controls to pause, scrub through, skip around, etc.)
While they're at it, they could also allow embedding of some kind of slide-deck format. Using GIFs for slides has all the same problems. (Hopefully nothing as fancy/complex as PPT; more like a basic-PostScript-profile PDF renderer, that would auto-carousel through the PDF's pages, until you begin interacting with it.)
Not even through `animation-play-state: paused;`? e.g:
:hover {
animation-play-state: paused;
}I mean for that matter I could just use an iFrame to embed a HTML file.
Reference: https://samy.pl/myspace/tech.html
https://raw.githubusercontent.com/sindresorhus/css-in-readme...
i.e. make the "login" button invisible, hide some text, etc?
What have you done??
Actually, an animated SVG. Sigh.
Don't get me wrong, documenting your work is very important, but do it efficiently.
Github Readme's are turning more and more into developer myspace.
Just keep it text, to the point, start with why someone should care, then once they care, show them how to use it.
When I see some kind of video embed, it's a huge turn off, I don't want to watch some animation of your typos at high speed, or your fish terminal.
"Show me the money".
Edit: my point is: spend your time making your code better, sorting, fixing and clear your issues and merge or reject decade old PRs /s
For reference:
The IETF nails it with their RFCs, e.g.:
I don't see why the PDF should use the Notepad look - one can be too spartan.
However.
We're not talking about web sites here, we're talking about README files. They should be absolutely readable and understandable if you're displaying them in a console -- that's arguably one of the underlying tenets of Markdown as it was originally conceived (e.g., that its source be as easily readable as a plain text email or Usenet message is). I like that GitHub renders Markdown documents, but a lot of time when you're mucking around with source, you're looking at, well, the plain document.
I think this is a fun hack to demonstrate how you can do ridiculous things in technically-still-Markdown documents, but it's unequivocally not something anyone should actually do in their Markdown documents. :)
If it's a graphical tool a screenshot can help a lot in deciding it of does what I need.
If it's a library a quick code snippet can give me a feel of whether it'll be a good fit for my project
I do tend to agree about the "Developer MySpace" feel of a lot of repos though.
I don't think a better description is possible
If the project is meant to be shared with the community, the README should contain at least enough rich content to convey what it does.
There’s definitely a valid use case for more visually expressive walk up experiences for many code projects that could and IMO should be supported at the repository host level. It doesn’t have to be myspace but it could definitely support more embedded example cases and at least some personality.
You're also assuming your perception of the README is how most people consume it. To that end, I'll offer a counter-anecdote, I very much want a README to convey to me how the project is: built, used, and what I should know about contributing to it. For usage, having images and videos for certain tools is priceless.