ioquatix / jquery-syntax

jQuery.Syntax is a light-weight client-side syntax highlighter.
MIT License
129 stars 27 forks source link

$('#codefile-pre').syntax() doesn't work #7

Closed tshi0912 closed 7 years ago

tshi0912 commented 10 years ago

Only $.syntax() worked, however with selected jquery object, it doesn't work, even through it's exampled, such as: $('div.java').syntax({ brush: 'java', layout: 'fixed', tabWidth: 8, replace: true });

ioquatix commented 10 years ago

I just checked and it is working on my end. Can you give me a full example?

tshi0912 commented 10 years ago

I find out it should specify both 'layout' and 'blockLayout' at the sametime, otherwise it doesn't work. My code fragment is generated dynamically via ajax call, once the code text retrieved from server side, I will invoke synatx api to create the synatx view, below is the my code for you reference:

 
               $.ajax({
                dataType : 'json',
                url : '/codefiles/xxx.java' +  
            }).done(function(data){
                $('#codefile-td').empty();
                $('#codefile-td').append('<pre></pre>');
                $('#codefile-td pre').text(data.text);
                $('#codefile-td pre').syntax({
                    theme: 'paper',
                    layout: 'fixed',
                    blockLayout: 'fixed',
                    replace: true
                }, function (options, html, container) {
                    // Draw cover block
                    return html;
                });
            });
ioquatix commented 7 years ago

Thanks. I will consider this issue you had when reviewing the documentation so it could be clear for new users.