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

Use prettyPrint opt_whenDone callback to resolve a deferred #5

Open
mickmcgrath13 opened this issue Nov 10, 2016 · 0 comments
Open

Comments

@mickmcgrath13
Copy link
Contributor

Original issue: canjs/canjs/issues/2706
Dependent on: canjs/bit-docs-html-canjs/issues/189

The prettyPrint method takes a couple of parameters, the first of which is a function to be executed when the prettifying is complete. (See here).

Where we call the prettyPrint method, we could provide a return value of a Deferred which is resolved within prettyPrint's done callback.

Something like:

    require('./prettify-engine');
    require('./prettify.less');
    var $ = require('jquery');
    module.exports = function () {
    	var doneDeferred = $.Deferred();
        var codes = document.getElementsByTagName('code');
        for (var i = 0; i < codes.length; i++) {
            var code = codes[i];
            if (code.parentNode.nodeName.toUpperCase() === 'PRE') {
                code.className = code.className + ' prettyprint';
            }
        }
        prettyPrint(function(){
        	doneDeferred.resolve();
        });
        
        return doneDeferred;
    };
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

No branches or pull requests

1 participant