Skip to content
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

Remove file-highlight plugin from prism.js. #127

Closed
wants to merge 2 commits into from
Closed

Remove file-highlight plugin from prism.js. #127

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jun 24, 2013

This plugin loading as component described at components.js.

File Prism.js executes at worker. This leads to error, b/c of the window and document objects are absent at worker.

Fix for #123

@LeaVerou
Copy link
Member

Hi,

prism.js is the website's build of prism, not the build you're supposed to download. On the Prism website, Prism does not run asynchronously, so I don't see the problem.

@ghost
Copy link
Author

ghost commented Jun 24, 2013

https://github.com/katsgeorgeek/prism/blob/676651ec9175079b46b40ee83f4c5ecd5c45d94f/prism.js#L152

Here prism.js executes at worker. And this part of code runs https://github.com/LeaVerou/prism/blob/gh-pages/prism.js#L513.

On download page you can see this error:

Uncaught ReferenceError: window is not defined prism.js:513

B/c of this page is available for user after some time.

@LeaVerou
Copy link
Member

  1. I know that Prism has an async mode that uses workers, I wrote it :-) My question was which page in the Prism website uses that mode. Is it async on the download page?
  2. That window.Prism should be changed to self.Prism. Then that error won't be thrown (though maybe another one will). But in general it's good practice to use self instead of window so if you could change that I'd be grateful :)
  3. I cannot remove the entire file highlight plugin from the entire prism.js script, it's actually needed in the Prism website. It's not decorative.

@ghost
Copy link
Author

ghost commented Jun 24, 2013

  1. Yes, download page.
  2. self.Prism will be work. But this part of code use document binding. https://github.com/LeaVerou/prism/blob/gh-pages/prism.js#L523
  3. I can move this functional to the separate file. Please name me the page, which needs it.

@LeaVerou
Copy link
Member

I think the best solution would be to make the file highlight plugin compatible to run in a worker context.
E.g. check for the presence of self.document in the beginning if. That should solve it in a much better way.

@ghost
Copy link
Author

ghost commented Jun 24, 2013

I'm not sure that this is the best solution. But I force updated my pull request.

@LeaVerou
Copy link
Member

What are your reservations about it?
People might include this plugin and then run Prism asynchronously. It's not just a problem with the Prism website so it shouldn't be fixed in the Prism website. IMO.

Regarding the pull request, I think it's better if you send a new one. This one has merge conflicts too.

@LeaVerou LeaVerou closed this Jun 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant