highlight js doenst highlight code in Drupal cms 2.x D11
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3584177. -->
Reported by: [joachim namyslo](https://www.drupal.org/user/275771)
Related to !11
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>I installed Drupal CMS 2.x with the Convivial Template provided by morpht yesterday and than installed highlight js because prismjs syntax highlighter didn't highlight any code at all. </p>
<p>I than realized that highlightjs did not work eiter. </p>
<p>It just worked when I had loaded the highlight.js file globaly within the theme.</p>
<p>By prompting some ai tool I could at least made it work again. </p>
<p><strong>I don't expect you to incorporate this AI patch into the module as an MR at all.<br>
</strong><br>
All I can say is that, with this patch, the module works perfectly for me in Drupal 11.3.6. </p>
<p>The code might help you with testing. That's why I'm attaching the file.</p>
<p>Here is the summary of what was fixed there:</p>
<blockquote><ul>
<li>Service Name Normalization: Corrected the typo ckedito5 to ckeditor5. This ensures that the plugin manager is correctly injected and matches standard Drupal naming conventions, preventing container initialization failures in Drupal 11.</li>
<li>Global Attachment Hook: Added hook_page_attachments to highlight_js.module. This was necessary because many modern Drupal themes and component libraries (including Morphos and Canvas) can sometimes lose attachments generated by text filters during the render pipeline. Moving the core library and configuration load to the page level ensures the highlighter is always available when the module is enabled.</li>
<li>JavaScript Modernization: Refactored highlight-custom.js to use the standardized once pattern required for Drupal 10/11. I also added safety checks for external dependencies (hljs, ClipboardJS) and improved unique ID generation to prevent collisions when multiple code snippets are present on a single page.</li>
<li>Robust Parsing: Updated the text filter to use regular expressions for attribute extraction. This makes the module resilient to variations in HTML attribute order or quoting styles (single vs. double) produced by different CKEditor 5 configurations.</li>
<li>Language Class Cleanup: Filtered the language identifier to ensure that comma-separated lists (like bash, sh, zsh) are converted into a single, valid Highlight.js language class.</li>
<li>patch</li>
<li>
</ul>
</blockquote>
<p>Since this is an AI patch that I had the AI generate yesterday out of sheer desperation because the module wasn't working with my D11 setup, please just close the issue if you don't find the code helpful or can't reproduce the described issue.<br>
I'd still appreciate a review, though. </p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>Install Drupal CMS with comvivial gov theme from the site template selct screen in browser<br>
Install and enable highlight.js<br>
Set up the ckeditor filter and button<br>
Creeate an article<br>
add some code<br>
see if highlighting and the copy button works</p>
<p>With out the patch it shouldn't work at all<br>
With the patch applied it should work like a charm again.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>review the parts mentioned in the patch file and sumary below against the modules current release.<br>
create a MR </p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3 id="summary-ui-changes">User interface changes</h3>
<h3 id="summary-api-changes">API changes</h3>
<h3 id="summary-data-model-changes">Data model changes</h3>
> Related issue: [Issue #3280235](https://www.drupal.org/node/3280235)
issue
GitLab AI Context
Project: project/highlight_js
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/highlight_js/-/raw/1.x/README.txt — project overview and setup
Repository: https://git.drupalcode.org/project/highlight_js
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD