Skip to content

[#132] Add Highlight.js syntax highlighter#137

Closed
StevenWalker98 wants to merge 2 commits intodrevops:developfrom
StevenWalker98:feature/132-highlight-js
Closed

[#132] Add Highlight.js syntax highlighter#137
StevenWalker98 wants to merge 2 commits intodrevops:developfrom
StevenWalker98:feature/132-highlight-js

Conversation

@StevenWalker98
Copy link
Copy Markdown
Contributor

@StevenWalker98 StevenWalker98 commented Feb 18, 2026

Closes #132

Changes

Adds the Highlight.js module for source code syntax highlighting in CKEditor 5.

  • Added drupal/highlight_js ^1.2 to composer.json
  • Enabled module in core.extension.yml
  • Added highlight_js.settings.yml — GitHub theme, copy button enabled
  • Updated civictheme_rich_text text format:
    • Added highlight_js filter
    • Added <highlight-js> to allowed HTML tags
  • Updated CKEditor config:
    • Added highlightJs toolbar button
    • Added highlight_js module dependency

Note

composer.lock needs updating — could not run composer update locally due to SSH access issue with drevops/test-private-package. This will need to be resolved in CI or by someone with the private repo access.

Theme

Set to github — clean and professional. Can be changed at /admin/config/content/highlight-js.

Summary by CodeRabbit

  • New Features
    • Syntax highlighting functionality added to the rich text editor with a dedicated toolbar button
    • Copy-to-clipboard feature for highlighted code blocks
    • Configurable theme and styling options for code highlighting, including color customization and transparency settings

- Added drupal/highlight_js ^1.2 to composer.json
- Enabled highlight_js module in core.extension
- Added highlight_js.settings.yml with GitHub theme
- Added highlight_js filter to civictheme_rich_text format
- Added <highlight-js> to allowed HTML tags
- Added highlightJs toolbar button to CKEditor config
- Added highlight_js module dependency to editor config

Note: composer.lock needs to be updated by running composer update
drupal/highlight_js in an environment with SSH access to private repos.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 18, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds the Drupal highlight_js module as a dependency to enable source code syntax highlighting. Updates Composer configuration, registers the module in core extensions, and configures editor toolbar integration and filter settings with styling options.

Changes

Cohort / File(s) Summary
Dependency Management
composer.json
Added drupal/highlight_js ^1.2 to require dependencies.
Module Registration
config/default/core.extension.yml
Registered highlight_js module with initial status 0.
Editor Integration
config/default/editor.editor.civictheme_rich_text.yml
Added highlightJs toolbar button with separator; declared module dependency.
Filter Configuration
config/default/filter.format.civictheme_rich_text.yml
Added highlight_js filter with weight -40; updated filter_html allowed_html to include class attributes on anchor and button elements; declared module dependency.
Module Settings
config/default/highlight_js.settings.yml
Created new configuration file defining copy button behavior, color settings (background, text, success states), language/theme defaults, and transparency flags.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

PR: DO NOT MERGE

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely describes the main change: adding Highlight.js syntax highlighter integration, which aligns with the primary objective.
Linked Issues check ✅ Passed The code changes fully implement the primary objective from issue #132: integrating Highlight.js into the site for source code syntax highlighting.
Out of Scope Changes check ✅ Passed All changes are directly related to integrating Highlight.js: dependency addition, module enablement, configuration files, filter setup, and editor integration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@composer.json`:
- Line 31: composer.json added the dependency "drupal/highlight_js": "^1.2" but
composer.lock was not updated, breaking CI; run Composer locally (for example:
composer require drupal/highlight_js:^1.2 or composer update drupal/highlight_js
--with-dependencies) to regenerate composer.lock, verify the lock now contains
drupal/highlight_js@1.2.x, then commit and push the updated composer.lock
alongside the composer.json change so the CI can pass.

In `@config/default/filter.format.civictheme_rich_text.yml`:
- Line 56: Replace the malformed empty-mapping syntax in
filter.format.civictheme_rich_text.yml: change the line "settings: {  }" to use
a compact empty mapping "settings: {}" (no spaces inside braces) so it matches
YAMLlint rules and the style used in highlight_js.settings.yml.

In `@config/default/highlight_js.settings.yml`:
- Around line 8-9: Replace the invalid empty-brace formatting for the YAML keys
role_copy_access and languages by changing their values from "{  }" to "{}" so
they are valid empty mappings for YAMLlint; update both occurrences
(role_copy_access: {  } -> role_copy_access: {} and languages: {  } ->
languages: {}) and ensure no trailing spaces remain inside the braces.

Comment thread composer.json
provider: highlight_js
status: true
weight: -40
settings: { }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix YAML empty-brace formatting (YAMLlint error)

settings: { } uses spaces inside the empty mapping braces, matching the same YAMLlint violation as in highlight_js.settings.yml.

🛠️ Proposed fix
-    settings: {  }
+    settings: {}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
settings: { }
settings: {}
🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 56-56: too many spaces inside empty braces

(braces)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/default/filter.format.civictheme_rich_text.yml` at line 56, Replace
the malformed empty-mapping syntax in filter.format.civictheme_rich_text.yml:
change the line "settings: {  }" to use a compact empty mapping "settings: {}"
(no spaces inside braces) so it matches YAMLlint rules and the style used in
highlight_js.settings.yml.

Comment on lines +8 to +9
role_copy_access: { }
languages: { }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix YAML empty-brace formatting (YAMLlint error)

Both role_copy_access and languages use { } (spaces inside braces), which fails YAMLlint. Use {} to represent empty mappings.

🛠️ Proposed fix
-role_copy_access: {  }
-languages: {  }
+role_copy_access: {}
+languages: {}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
role_copy_access: { }
languages: { }
role_copy_access: {}
languages: {}
🧰 Tools
🪛 YAMLlint (1.38.0)

[error] 8-8: too many spaces inside empty braces

(braces)


[error] 9-9: too many spaces inside empty braces

(braces)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/default/highlight_js.settings.yml` around lines 8 - 9, Replace the
invalid empty-brace formatting for the YAML keys role_copy_access and languages
by changing their values from "{  }" to "{}" so they are valid empty mappings
for YAMLlint; update both occurrences (role_copy_access: {  } ->
role_copy_access: {} and languages: {  } -> languages: {}) and ensure no
trailing spaces remain inside the braces.

@StevenWalker98 StevenWalker98 deleted the feature/132-highlight-js branch February 18, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add source code hilighter

1 participant