Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm following your instructions to add C++. I have built hightlight.js to include C++, (I believe it's called cpp in the .js file). But I'm absolutely perplexed by "create module and attach hook". Can you elaborate for the new drupal user?
Thanks,
M
Comment | File | Size | Author |
---|---|---|---|
#3 | codesnippet.png | 52.95 KB | kevinquillen |
Comments
Comment #2
monty_t_hall CreditAttribution: monty_t_hall commentedComment #3
kevinquillen CreditAttribution: kevinquillen at Velir commentedAt the moment, in order to create the option for C++, you will need to create a simple module that will implement hook_form_FORM_ID_alter().
Below is an example of what your module might look like. Instead of mymodule, your module name would be something like codesnippet_extras. Let's assume that is the case.
In your MYMODULE.module file, you would put this:
You don't necessarily need the asort() line, but I like the languages to be alphabetical (thats just me). This alter only fires when viewing the text filter format form and if codesnippet is present in the form array.
Attached is a pic of the result when the new module is enabled.
Sorry if it seems like a bit much for a newcomer, but I wanted to avoid going the kitchen sink route with HightlightJS - it would mean an additional like 220kb JS file being loaded per page just to cover all the bases of syntax highlighting.
Comment #5
kevinquillen CreditAttribution: kevinquillen at Velir commentedI've updated the documentation to reflect this working example as well as the project page.
Comment #6
kevinquillen CreditAttribution: kevinquillen at Velir commented