WordPress.org

Ready to get started?Download WordPress

Forums

WP-Syntax
[resolved] Javascript not highlighted? (7 posts)

  1. Steven Vachon
    Member
    Posted 1 year ago #

    lang="javascript" line="1" adds the line numbers and the other wrapper code, but it does not highlight. Perhaps a bug in GeSHi?

    http://wordpress.org/extend/plugins/wp-syntax/

  2. shazahm1
    Member
    Plugin Author

    Posted 1 year ago #

    @Steven Vachon

    It highlight JS fine for me.

  3. Steven Vachon
    Member
    Posted 1 year ago #

  4. shazahm1
    Member
    Plugin Author

    Posted 1 year ago #

    Hmmm, this definitely works for me. You have the latest version of WP-Syntax installed?

    Can you paste a copy of the entire pre block in you post here between backtick?

  5. Steven Vachon
    Member
    Posted 1 year ago #

    <p>For ActionScript:</p>
    <pre lang="actionscript" line="1">function shuffleArray(array:Array):Array
    {
    	var len:int = array.length;
    
    	for (var i:int=0; i<len; i++)
    	{
    		var j:int = Math.round( Math.random() * (len-1) );
    
    		var value:* = array[i];
    
    		array[i] = array[j];
    		array[j] = value;
    	}
    
    	return array;
    }</pre>
    
    <p>For JavaScript:</p>
    <pre lang="javascript" line="1">function shuffleArray(array)
    {
    	var len = array.length;
    
    	for (var i=0; i<len; i++)
    	{
    		var j = Math.round( Math.random() * (len-1) );
    
    		var value = array[i];
    
    		array[i] = array[j];
    		array[j] = value;
    	}
    
    	return array;
    }</pre>
  6. shazahm1
    Member
    Plugin Author

    Posted 1 year ago #

    Interesting. I can add exactly what you have and it works fine for me. For some reason GeSHi just seems to be not highlighting it for you.

  7. Steven Vachon
    Member
    Posted 1 year ago #

    I'd forgotten that I'd added this to my code:

    add_action('wp_syntax_init_geshi', 'wp_syntax_config');
    
    function wp_syntax_config(&$geshi)
    {
    	$geshi->enable_classes();
    	$geshi->enable_keyword_links(true);
    	$geshi->enable_strict_mode(true);	// problematic
    }

    With strict mode disabled, it works fine. I'd enabled it at one point when I'd encountered an issue with <?php tags. Seems to be fine now, but it's very possible that it could cause an issue in the future.

    But, still... why does JavaScript not work in strict mode? If you can, please fix this

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.