Skip to content

[#375] Loaded the 'apache' and 'nginx' highlight.js languages for code blocks. - #377

Merged
AlexSkrypnyk merged 1 commit into
developfrom
feature/375-highlight-languages
Nov 16, 2026
Merged

AlexSkrypnyk merged 1 commit into
developfrom
feature/375-highlight-languages

Conversation

@AlexSkrypnyk

Copy link
Copy Markdown
Member

Closes #375

Checklist before requesting a review

  • Subject includes ticket number as [#123] Verb in past tense.
  • Ticket number #123 added to description
  • Added context in Changed section
  • Self-reviewed code and commented in commented complex areas.
  • Added tests for fix/feature.
  • Relevant tests run and passed locally.

Summary

Code blocks in civictheme_rich_text content tagged language-apache or language-nginx now load their highlight.js grammar, so they render highlighted alongside language-gherkin.

The highlight_js module loads only the cdnjs 11.9.0 common bundle (highlight.min.js), which has no Apache or Nginx grammar, so a page like the October 2026 PHP vulnerabilities post logged Could not find the language 'apache' and 'nginx' and fell back to plain text. The module's languages setting only fills the editor dialog's dropdown and never attaches a grammar, so this can't be fixed in settings.

After merge, any page that attaches highlight_js/highlight_js.custom also loads apache.min.js and nginx.min.js from cdnjs 11.9.0, which script-src in csp.settings.yml already admits through https://cdnjs.cloudflare.com. The CKEditor code block language list in editor.editor.civictheme_rich_text.yml is unchanged.

Before / After

BEFORE
  highlight_js/highlight_js.custom
    ├── highlight_js/highlight_js.js   (common bundle, no apache/nginx)
    └── do_base/highlight_js.gherkin

  <code class="language-apache">  ──▶  WARN, no highlighting
  <code class="language-nginx">   ──▶  WARN, no highlighting

AFTER
  highlight_js/highlight_js.custom
    ├── highlight_js/highlight_js.js
    ├── do_base/highlight_js.apache    ─┐
    ├── do_base/highlight_js.gherkin    ├─ added from LibraryInfoAlterHook::HIGHLIGHT_LANGUAGES
    └── do_base/highlight_js.nginx     ─┘

  <code class="language-apache">  ──▶  highlighted
  <code class="language-nginx">   ──▶  highlighted

Changed

  1. do_base.libraries.yml: added highlight_js.apache and highlight_js.nginx, each loading its grammar from cdnjs 11.9.0 (the same version as the module's core bundle) and depending on highlight_js/highlight_js.js, like the existing highlight_js.gherkin.
  2. LibraryInfoAlterHook: the extra languages live in a HIGHLIGHT_LANGUAGES constant, and the hook loops over it to add each do_base/highlight_js.<language> dependency to highlight_js.custom.
  3. LibraryInfoAlterHookTest: asserts all 3 dependencies in order, checks each language has a library in do_base.libraries.yml pointing at the cdnjs URL, and covers another extension's highlight_js.custom being left alone.

Screenshots

N/A

@AlexSkrypnyk AlexSkrypnyk added the A2 Board worker 2 label Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 46 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 91 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 919afcca-484c-4675-8de7-55c3a9748e55
Commits

Reviewing files that changed from the base of the PR and between e4c6f5f and fbf780f.

Files selected for processing: 3

  • web/modules/custom/do_base/do_base.libraries.yml
  • web/modules/custom/do_base/src/Hook/LibraryInfoAlterHook.php
  • web/modules/custom/do_base/tests/src/Unit/LibraryInfoAlterHookTest.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@AlexSkrypnyk AlexSkrypnyk added the AUTOMERGE Pull request has been approved and set to automerge label Nov 16, 2026
@github-actions

Copy link
Copy Markdown

Code coverage (threshold: 80%)

  Classes: 63.16% (24/38)
  Methods: 83.22% (119/143)
  Lines:   89.95% (967/1075)
Per-class coverage
Drupal\do_ai_alt_text\AltTextGenerator
  Methods:  85.71% ( 6/ 7)   Lines:  98.72% ( 77/ 78)
Drupal\do_ai_alt_text\Plugin\Action\RegenerateImageAltText
  Methods: 100.00% ( 8/ 8)   Lines: 100.00% ( 63/ 63)
Drupal\do_analytics\AnalyticsAttributes
  Methods: 100.00% ( 7/ 7)   Lines: 100.00% ( 29/ 29)
Drupal\do_analytics\Hook\FormAlterHook
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  3/  3)
Drupal\do_analytics\Hook\PageAttachmentsHook
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 13/ 13)
Drupal\do_analytics\Hook\PreprocessHook
  Methods: 100.00% ( 7/ 7)   Lines: 100.00% ( 27/ 27)
Drupal\do_base\EventSubscriber\PreviewLinkCacheSubscriber
  Methods:  33.33% ( 1/ 3)   Lines:  11.11% (  1/  9)
Drupal\do_base\EventSubscriber\ThemeColorSubscriber
  Methods:  66.67% ( 2/ 3)   Lines:  40.00% (  4/ 10)
Drupal\do_base\Hook\AutomatedListPagerHook
  Methods: 100.00% ( 5/ 5)   Lines: 100.00% ( 31/ 31)
Drupal\do_base\Hook\LibraryInfoAlterHook
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 12/ 12)
Drupal\do_base\Hook\MetatagsAlterHook
  Methods: 100.00% ( 7/ 7)   Lines: 100.00% ( 58/ 58)
Drupal\do_base\Hook\PageAttachmentsHook
  Methods:  87.50% ( 7/ 8)   Lines:  96.61% ( 57/ 59)
Drupal\do_base\Hook\SvgMediaHook
  Methods:  75.00% ( 3/ 4)   Lines:  96.15% ( 25/ 26)
Drupal\do_base\Hook\TwigValidatorRuleInfoAlterHook
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  3/  3)
Drupal\do_base\NavigationScriptHash
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 27/ 27)
Drupal\do_base\SvgDimensions
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% ( 13/ 13)
Drupal\do_base\Twig\IconAssetsExtension
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% (  3/  3)
Drupal\do_base\Twig\ImageDimensionsExtension
  Methods:  60.00% ( 3/ 5)   Lines:  93.02% ( 40/ 43)
Drupal\do_content_api\EventSubscriber\JsonApiWriteGateSubscriber
  Methods:  66.67% ( 2/ 3)   Lines:  88.89% (  8/  9)
Drupal\do_content_api\Hook\EntityCreateAccessHook
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 12/ 12)
Drupal\do_content_api\Hook\ModerationPolicyHook
  Methods:  50.00% ( 1/ 2)   Lines:  93.75% ( 15/ 16)
Drupal\do_content_api\Routing\RouteSubscriber
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 11/ 11)
Drupal\do_feed\FeedUrlBuilder
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 18/ 18)
Drupal\do_feed\Form\FeedSettingsForm
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 15/ 15)
Drupal\do_feed\Hook\EntityDeleteHook
  Methods:  50.00% ( 1/ 2)   Lines:  92.31% ( 12/ 13)
Drupal\do_feed\Hook\EntityPresaveHook
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 54/ 54)
Drupal\do_feed\Hook\PreprocessParagraphHook
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 14/ 14)
Drupal\do_feed\Hook\PreprocessViewsViewRowRssHook
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  3/  3)
Drupal\do_feed\Hook\ViewsPreViewHook
  Methods:  50.00% ( 1/ 2)   Lines:  96.43% ( 27/ 28)
Drupal\do_generated_content\Generator\CaseMatrix
  Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 12/ 12)
Drupal\do_generated_content\Generator\RelativeDate
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  1/  1)
Drupal\do_package\Hook\PackageAccessHook
  Methods: 100.00% ( 7/ 7)   Lines: 100.00% ( 27/ 27)
Drupal\do_package\Hook\PackageFileHook
  Methods: 100.00% (11/11)   Lines: 100.00% ( 40/ 40)
Drupal\do_package\Routing\RouteSubscriber
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  5/  5)

@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.96%. Comparing base (e4c6f5f) to head (fbf780f).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #377      +/-   ##
===========================================
+ Coverage    87.94%   87.96%   +0.01%     
===========================================
  Files           39       39              
  Lines          863      864       +1     
===========================================
+ Hits           759      760       +1     
  Misses         104      104              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Nov 16, 2026
@AlexSkrypnyk
AlexSkrypnyk merged commit 019516a into develop Nov 16, 2026
16 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/375-highlight-languages branch November 16, 2026 09:57

This branch was successfully deployed

1 active deployment
PR-377 — fbf780f9 Deployed Nov 16, 2026 by AlexSkrypnyk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A2 Board worker 2 AUTOMERGE Pull request has been approved and set to automerge Needs review Pull request needs a review from assigned developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Load the 'apache' and 'nginx' highlight.js languages for blog code blocks

1 participant