-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Doubly check the manual
flag
#1957
Conversation
Misunderstood the requirement to not touch anything outside of |
This pull request is the only PR that is not labeled at all, so it looks like it might have slipped through the cracks. Can you take a look, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay @TimWolla!
All in all, I'm ok with this aside from a few minor things (see comments).
Regarding the documentation:
I think we definetly need the doc (#1402) and should put this on your front page in the basic usage section (preferably above the CDN section).
Two or three sentences with one or two code example should be enough to sell the idea. The doc should mention Prism.manual
and data-manual
.
/cc @mAAdhaTTah
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made the requested adjustments to the code.
This can simply go into
So only |
Yes. I didn't notice it already mentioned |
Okay, I've added the docs as well. Let me know if there's something else I forgot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still like to have @mAAdhaTTah approve this.
Just need to resolve the conflicts. |
Currently the `manual` is only checked before attaching the event listener, making it hard to reliably set the flag without jumping through hoops and special cases if Prism is bundled together with other scripts into a single script file. Change to check the flag once before attaching the event listener and once again before actually highlighting to support setting it after the Prism initialization has run. see discussion starting at: #1087 (comment)
@mAAdhaTTah I've rebased my branch onto PrismJS:master and resolved the conflicts. |
Thank you for contributing @TimWolla! |
components/prism-core.js
Outdated
@@ -533,21 +533,21 @@ if (script) { | |||
_.filename = script.src; | |||
|
|||
if (!_.manual && !script.hasAttribute('data-manual')) { | |||
_.highlightAutomaticallyCallback = function () { | |||
function highlightAutomaticallyCallback() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change it's not possible to minify script using uglify-js and "use strict"
declaration:
13971 |
13972 | if (!_.manual) {
> 13973 | function highlightAutomaticallyCallback() {
| ^ In strict mode code, functions can only be declared at top level or immediately within another function.
13974 | if (!_.manual) {
13975 | _.highlightAll();
13976 | }
Functions shouldn't be declared inside the if code block.
Currently the
manual
is only checked before attaching the eventlistener, making it hard to reliably set the flag without jumping
through hoops and special cases if Prism is bundled together with
other scripts into a single script file.
Change to check the flag once before attaching the event listener
and once again before actually highlighting to support setting it
after the Prism initialization has run.
see discussion starting at:
#1087 (comment)
Quoting from the discussion in the issue:
and
Should I make some other adjustments anywhere? /cc @mAAdhaTTah