Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

small changes so that it can be used directly in a npm pipeline #476

Merged
merged 8 commits into from
Nov 3, 2017

Conversation

alex-milanov
Copy link
Contributor

@alex-milanov alex-milanov commented Feb 17, 2017

usage in a node module

const prettify = require('code-prettify')
// default
prettify.prettyPrint();
// single use
document.querySelector('pre > code').innerHTML = prettify.prettyPrintOne('function() {console.log('foo');}');

usage in a task automation (like gulp, grunt...) for css preprocessor (like sass, less)

require('code-prettify').includePaths

then inside a sass file

@import 'prettify'

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@alex-milanov
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

This was referenced Feb 17, 2017
@alex-milanov alex-milanov changed the title simple changes so that it can be used directly in a npm pipeline small changes so that it can be used directly in a npm pipeline Feb 17, 2017
@alex-milanov
Copy link
Contributor Author

Just some updates.

I've successfully used my fork as a npm package (npm i -S alex-milanov/code-prettify) with browserify for a simple code editor for the slides app for a local talk I did on functional reactive javascript.

You can check:

Examples of usage:

Can someone check if there are potential side effects from the changes I made so that we can merge the PR? If there are we can discuss them so that I can make the needed modifications.

//cc @amroamroamro @mikesamuel

@alex-milanov
Copy link
Contributor Author

btw. I created a gitter chat room for my fork at https://gitter.im/alex-milanov/code-prettify (You guys could create an "official" one or join the one I created, both options work for me)

@alex-milanov alex-milanov mentioned this pull request Mar 3, 2017
@ateev
Copy link

ateev commented May 2, 2017

@alex-milanov Thanks for this ! Why isn't this merged with the original project yet ?

@alex-milanov
Copy link
Contributor Author

@ateev beats me.

//cc @amroamroamro @mikesamuel

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@alex-milanov
Copy link
Contributor Author

@yuschick seems you have to sign a google CLA (Contributor License Agreement).
Don't how relevant this is since this PR has been opened since Feb 18.

src/prettify.js Outdated
@@ -141,7 +141,8 @@ var PR;
* UI events.
* If set to {@code false}, {@code prettyPrint()} is synchronous.
*/
window['PR_SHOULD_USE_CONTINUATION'] = true;
var PR_SHOULD_USE_CONTINUATION = true;
if (typeof window !== 'undefined') window.PR_SHOULD_USE_CONTINUATION = PR_SHOULD_USE_CONTINUATION;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these changes need to be made in https://github.com/google/code-prettify/blob/master/js-modules/prettify.js#L94

Please also use brackets around if bodies.

Also, please use ['...'] form so that it is closure-compiler compatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I will check it out. btw. wouldn't it be more logical to have the sources in the src folder and the destination in a dist one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikesamuel also aren't these vars constants -> can we use

const PR_SHOULD_USE_CONTINUATION = true;

src/prettify.js Outdated
@@ -1740,3 +1741,14 @@ var prettyPrint;
});
}
})();

// npm require support
if (module && module.exports) module.exports = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't if(module) throw an exception if there is no global named "module".

Maybe if (typeof module !== 'undefined' && module.exports)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it shouldn't be an issue in most cases but the second one would be more consistent.

@alex-milanov
Copy link
Contributor Author

@mikesamuel after struggling for a while with the closure compile process and stumbling upon how run_prettify is formed found a way to add node support by introducing js-modues/node_prettify.js and modifying the preprocess and copy:prettify grunt tasks.
Also pointed the main in package.json (used only in node I hope) to src/node_prettify.js
//cc @yuschick Can you confirm it also works in your setup?

@alex-milanov
Copy link
Contributor Author

@mikesamuel I hope we won't have to wait 6 more months for a response :-)

@evolve2k
Copy link

evolve2k commented Nov 1, 2017

Bump.

@evolve2k
Copy link

evolve2k commented Nov 1, 2017

Looks good to me. Let's merge this in.

@mikesamuel mikesamuel merged commit 8913c2f into googlearchive:master Nov 3, 2017
@mikesamuel
Copy link
Contributor

Thanks for doing this. Sorry for taking so long to get back to it.

@evolve2k
Copy link

evolve2k commented Nov 3, 2017

Thank you everyone!!! 🙌🎉

evolve2k added a commit to demingfactor/dash-of-style that referenced this pull request Nov 6, 2017
…ushed to master 3 Nov. This is so that it can be used as a npm module.

googlearchive/code-prettify#476
@evolve2k
Copy link

evolve2k commented Nov 6, 2017

Any possibility of doing a new public release to help get this feature out into the wild? 🦁

@alex-milanov
Copy link
Contributor Author

If you need help I am available

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants