New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test page: Added variable source #1758
Conversation
Actually, files loaded using the |
- Better path handling - Better error messages and prompts - Early error checking in case of GitHub repos
I forget that I can't test the bot because the Danger code executed is from prism/master. |
Update: I scaled down the PR. It now only implements support for the Our lovely bot will now also add a link to the test page for the current PR. This will make it easy for anyone to try out language changes/additions. Here's an example of how a bot message may look like: JS File Size Changes (gzipped)A total of 1 files have changed, with a combined diff of +26 B (+1.4%).
Try it outI detect that some languages were changes. Everyone can try out the changes here. |
@mAAdhaTTah What do you think? This is something that will make contributing and reviewing easier, so I would like to merge this ASAP. |
While a nice quality-of-life feature, I don't think it is vital for this project and adds quite a bit of complexity to the test page. For those reasons, I'll now close this. |
This implements #1748 by using the URL hash to specify a
source
parameter.E.g.:
https://prismjs.com/test.html#source=<URL>
If
source
is not specified, the test page will behave as is does now.If
source
is specified, the test page will reloadcomponents.js
fromsource
and fetch all other Prism files via the specified URL (e.g.<URL>components/prism-c.js
).Themes
Themes are not affected by
source
.Please note that the current
components.js
of the PrismJS website will be loaded regardlessly. So we load ourcomponents.js
, handle our themes, and then load thecomponents.js
fromsource
(if specified) for language dependencies and to create the list of languages.Why is this useful?
My main motivation for this is reviewing.
Using combinatronics.com we can directly try the changes proposed in PRs (e.g.
https://prismjs.com/test.html#source=https://combinatronics.com/RunDevelopment/prism/html-attr-fix/
).My intention is to write a GitHub bot which automatically comments this link so we and other users can play with the changes.
This will only affect new PRs which change the languages of course.
Notes
Because
#
is an invalid character for file names, it is not possible to specifysource
if the file is opened directly from the local file system (AFAIK). A local server will work of course.I use a polyfill for
URLSearchParams
(used to parse the URL hash).This works for the latest versions of Chrome, Firefox, Edge, and IE11 on my machine.