The following snippet does not highlight

<code language="html">
<section itemscope itemtype="http://schema.org/Article">
  <h1 itemprop="name http://ogp.me/ns#title">How to Tie a Reef Knot</h1>
</section>

emptying chili_highlighter.js fixes the issue and forcing the load of recipes.js by adding

      drupal_add_js(
        $plugin_path . '/recipes.js',
        array('type' => 'file', 'group' => JS_LIBRARY, 'weight' => 0)
      );

to chili_highlighter_init() solves the issue.

The chili library is installed in sites/all/libraries/jquery.chili/ and I use chili-2.2

CommentFileSizeAuthor
#3 Test Chili highlighter | Drupal.png56.37 KBAnonymous (not verified)

Comments

scor’s picture

Title: Ni highlighting with 7.x-2.0-alpha6 » No highlighting with 7.x-2.0-alpha6
Anonymous’s picture

Status: Active » Postponed (maintainer needs more info)

What do you mean by "emptying chili_highlighter.js"?

Anonymous’s picture

Status: Closed (fixed) » Active
StatusFileSize
new56.37 KB

I didn't have to empty the "chili_hilighter.js" file; I changed the weight of the loaded JavaScript files, and it worked.

I changed the code of chili_highlighter_init() to the following one:

function chili_highlighter_init() {
  if ($plugin_path = chili_highlighter_plugin_path()) {
    $external = url_is_external($plugin_path);
    $module_path = drupal_get_path('module', 'chili_highlighter');
    $recipe_folder = $external ? $module_path . '/js/' : $plugin_path . '/';

    drupal_add_js(
      array(
        'chiliHighlighter' => array(
          'recipeFolder' => base_path() . $recipe_folder,
          'selector' => '.chili-highlighter',
        )
      ),
      'setting'
    );

    // Third-party modules can change the plugin path to an external link.
    if ($external) {
      drupal_add_js(
        $plugin_path,
        array('type' => 'external', 'group' => JS_LIBRARY, 'weight' => 0)
      );
    }
    else {
      drupal_add_js(
        $plugin_path . '/jquery.chili.js',
        array('type' => 'file', 'group' => JS_LIBRARY, 'weight' => 0)
      );
    }

    drupal_add_js(
      $plugin_path . '/recipes.js',
      array('type' => 'file', 'group' => JS_LIBRARY, 'weight' => 1)
    );

    drupal_add_js(
      $module_path . '/js/chili_highlighter.js',
      array('type' => 'file', 'group' => JS_LIBRARY, 'weight' => 2)
    );
  }
}

I also changed the content of the "chili_hilighter.js" file to the following one:

(function($) {

ChiliBook.lineNumbers = false;

Drupal.behaviors.chiliHighlighter = {
  attach: function(context, settings) {
    $(settings.chiliHighlighter.selector, context).once('chilihighlighter', function() {
      $(this).chili();
    });
  }
};

})(jQuery);

I still have to resolve a bug, which doesn't allows to select a different tag to highlight. Monday I will change the code to resolve that bug too, and I will commit the code to create a new official release.
After that I will back-port the code for Drupal 6.

Thank you for your report, and help in fixing this issue.

Anonymous’s picture

Issue summary: View changes

add more info on how to fix

Anonymous’s picture

Status: Postponed (maintainer needs more info) » Fixed

I have created a new official release.

Use the recipes attached in http://drupal.org/node/1270364.
The version associated with the filename is the minimum module version that uses those recipes. Use the file for the version that is closer to the version of the module you are using; for example, if you find two archives, recipes-7.x-2.0-alpha7.zip and recipes-7.x-2.0-alpha9.zip and you are using version 7.x-2.0-alpha11 of the module, then use the file recipes-7.x-2.0-alpha9.zip.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status: Active » Closed (fixed)