Commit f2ed35608c for handsontable.com

commit f2ed35608c2725a8e08fa16c519084a1df71e25b
Author: Artur Mędrygał <artur.medrygal@handsontable.com>
Date:   Wed Nov 25 13:25:22 2026 +0100

    DEV-4197: Fix docs defects found in the 19.0.0-rc7 QA pass (#14462)

    * DEV-4197: Close the code fence in the filterSelectedItems example

    Pin it with a test that checks every core JSDoc block closes its fences.

    * DEV-4197: Fix API anchors and document handsontable/themes/types

    * DEV-4197: Close the Hooks page fences and check fence nesting in the test

    Reword the themes/types section: the re-export compiles without an annotation.

    * DEV-4197: Lowercase absolute API anchors and report the fence's own line

    (cherry picked from commit b7318373d81e7196d7abcea2aca7c414551a9fba)

diff --git a/docs/content/guides/accessibility/accessibility/angular/example1.html b/docs/content/guides/accessibility/accessibility/angular/example1.html
index d20679fcac..3ac097dc97 100644
--- a/docs/content/guides/accessibility/accessibility/angular/example1.html
+++ b/docs/content/guides/accessibility/accessibility/angular/example1.html
@@ -93,7 +93,7 @@
           </div>
           <div>
             <label class="option-label" for="enable-cell-virtualization" id="cell-virtualization-label"><input checked type="checkbox" id="enable-cell-virtualization" name="enable-cell-virtualization" aria-labelledby="cell-virtualization-label" /> Enable cells virtualization</label>
-            <a href="https://handsontable.com/docs/javascript-data-grid/api/options/#renderAllRows" target="_blank" class="external-link" rel="noopener noreferrer" aria-label="Learn more about row virtualization (opens in a new window)">
+            <a href="https://handsontable.com/docs/javascript-data-grid/api/options/#renderallrows" target="_blank" class="external-link" rel="noopener noreferrer" aria-label="Learn more about row virtualization (opens in a new window)">
               <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg>
             </a>
           </div>
diff --git a/docs/content/guides/accessibility/accessibility/javascript/example1.html b/docs/content/guides/accessibility/accessibility/javascript/example1.html
index 565f4e248a..57511998b8 100644
--- a/docs/content/guides/accessibility/accessibility/javascript/example1.html
+++ b/docs/content/guides/accessibility/accessibility/javascript/example1.html
@@ -71,7 +71,7 @@
         Enable cells virtualization
       </label>
       <a
-        href="https://handsontable.com/docs/javascript-data-grid/api/options/#renderAllRows"
+        href="https://handsontable.com/docs/javascript-data-grid/api/options/#renderallrows"
         target="_blank"
         class="external-link"
         rel="noopener noreferrer"
diff --git a/docs/content/guides/accessibility/accessibility/react/example2.jsx b/docs/content/guides/accessibility/accessibility/react/example2.jsx
index 992f01e0ad..88a8edb96a 100644
--- a/docs/content/guides/accessibility/accessibility/react/example2.jsx
+++ b/docs/content/guides/accessibility/accessibility/react/example2.jsx
@@ -713,7 +713,7 @@ function DemoOptions({
             Enable cells virtualization
           </label>
           <a
-            href="https://handsontable.com/docs/react-data-grid/api/options/#renderAllRows"
+            href="https://handsontable.com/docs/react-data-grid/api/options/#renderallrows"
             target="_blank"
             className="external-link"
             rel="noopener noreferrer"
diff --git a/docs/content/guides/accessibility/accessibility/react/example2.tsx b/docs/content/guides/accessibility/accessibility/react/example2.tsx
index 95097bb558..14ad34b0ad 100644
--- a/docs/content/guides/accessibility/accessibility/react/example2.tsx
+++ b/docs/content/guides/accessibility/accessibility/react/example2.tsx
@@ -698,7 +698,7 @@ function DemoOptions({
               Enable cells virtualization
             </label>
             <a
-              href="https://handsontable.com/docs/react-data-grid/api/options/#renderAllRows"
+              href="https://handsontable.com/docs/react-data-grid/api/options/#renderallrows"
               target="_blank"
               className="external-link"
               rel="noopener noreferrer"
diff --git a/docs/content/guides/accessibility/accessibility/vue/example2.vue b/docs/content/guides/accessibility/accessibility/vue/example2.vue
index b906b79235..c3b9e662bd 100644
--- a/docs/content/guides/accessibility/accessibility/vue/example2.vue
+++ b/docs/content/guides/accessibility/accessibility/vue/example2.vue
@@ -627,7 +627,7 @@ const handleCheckboxChange = (checkboxName: string) => {
           Enable cells virtualization
         </label>
         <a
-          href="https://handsontable.com/docs/vue-data-grid/api/options/#renderAllRows"
+          href="https://handsontable.com/docs/vue-data-grid/api/options/#renderallrows"
           target="_blank"
           class="external-link"
           rel="noopener noreferrer"
diff --git a/docs/content/guides/cell-types/dropdown-cell-type/dropdown-cell-type.md b/docs/content/guides/cell-types/dropdown-cell-type/dropdown-cell-type.md
index 5a2dc7ea77..a0516ff638 100644
--- a/docs/content/guides/cell-types/dropdown-cell-type/dropdown-cell-type.md
+++ b/docs/content/guides/cell-types/dropdown-cell-type/dropdown-cell-type.md
@@ -464,7 +464,7 @@ The dropdown cell editor is an [autocomplete](@/guides/cell-types/autocomplete-c
 - [trimDropdown](@/api/options.md#trimdropdown)
 - [type](@/api/options.md#type)
 - [valueGetter](@/api/options.md#valuegetter)
-- [valueSetter](@/api/options.md#valueSetter)
+- [valueSetter](@/api/options.md#valuesetter)
 - [visibleRows](@/api/options.md#visiblerows)

 </div>
diff --git a/docs/content/guides/cell-types/handsontable-cell-type/handsontable-cell-type.md b/docs/content/guides/cell-types/handsontable-cell-type/handsontable-cell-type.md
index db4a945dd9..46ae995826 100644
--- a/docs/content/guides/cell-types/handsontable-cell-type/handsontable-cell-type.md
+++ b/docs/content/guides/cell-types/handsontable-cell-type/handsontable-cell-type.md
@@ -85,7 +85,7 @@ The **Product** column uses the handsontable cell type for a searchable product
 | Key | Action |
 | --- | --- |
 | <kbd>**Escape**</kbd> | Close editor and cancel change |
-| <kbd>**Enter**</kbd> | Close editor and apply change; move selection in the main HOT downwards or according to the [`enterMoves`](@/api/options.md#enterMoves) setting |
+| <kbd>**Enter**</kbd> | Close editor and apply change; move selection in the main HOT downwards or according to the [`enterMoves`](@/api/options.md#entermoves) setting |
 | <kbd>**Tab**</kbd> | Same as <kbd>**Enter**</kbd>, but move selection to the right or left according to the [`tabMoves`](@/api/options.md#tabmoves) setting |
 | <kbd>**Arrow Down**</kbd> | Move selection in HOT-in-HOT downwards. No effect if last row is selected |
 | <kbd>**Arrow Up**</kbd> | Move selection in HOT-in-HOT upwards. If the first row was selected, deselect. If HOT-in-HOT was deselected, behave as <kbd>**Enter**</kbd> but move main HOT selection upwards |
diff --git a/docs/content/guides/internationalization/layout-direction/layout-direction.md b/docs/content/guides/internationalization/layout-direction/layout-direction.md
index 9d54917989..43a6f4be97 100644
--- a/docs/content/guides/internationalization/layout-direction/layout-direction.md
+++ b/docs/content/guides/internationalization/layout-direction/layout-direction.md
@@ -108,7 +108,7 @@ Setting a different layout direction affects the behavior of the following areas
 | Text direction in cells                                                                                            | All cells inherit the LTR direction from the container element.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | All cells inherit the RTL direction from the container element.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
 | Position of row headers                                                                                            | Row headers are rendered on the left-hand edge of the grid.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Row headers are rendered on the right-hand edge of the grid.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
 | Position of [frozen columns](@/guides/columns/column-freezing/column-freezing.md)                                                  | Columns are frozen at the left-hand edge of the grid with [`fixedColumnsStart`](@/api/options.md#fixedcolumnsstart), and at the right-hand edge with [`fixedColumnsEnd`](@/api/options.md#fixedcolumnsend).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Columns are frozen at the right-hand edge of the grid with `fixedColumnsStart`, and at the left-hand edge with `fixedColumnsEnd`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
-| Position of the [fill handle](@/api/options.md#fillHandle)                                                         | The fill handle displays in the bottom-right corner of the selection border.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | The fill handle displays in the bottom-left corner of the selection border.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
+| Position of the [fill handle](@/api/options.md#fillhandle)                                                         | The fill handle displays in the bottom-right corner of the selection border.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | The fill handle displays in the bottom-left corner of the selection border.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
 | Position of the [selection](@/guides/cell-features/selection/selection.md) handles, on mobile devices                        | On mobile devices, the selection handles display in the top-left and bottom-right corners of the selection border.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | On mobile devices, the selection handles display in the top-right and bottom-left corners of the selection border.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
 | [Custom borders](@/guides/cell-features/formatting-cells/formatting-cells.md#custom-cell-borders)                                   | In the [`customBorders`](@/api/options.md#customborders) option:<br><br>- The left-hand border is treated as the starting border.<br>- The right-hand border is treated as the ending border.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | In the [`customBorders`](@/api/options.md#customborders) option:<br><br>- The right-hand border is treated as the starting border.<br>- The left-hand border is treated as the ending border.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
 | [Context menu](@/guides/accessories-and-menus/context-menu/context-menu.md) and [column menus](@/guides/accessories-and-menus/column-menu/column-menu.md) | Menus' layout direction is left-to-right.<br><br>Submenus expand to the right.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Menus' layout direction is right-to-left.<br><br>Submenus expand to the left.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
diff --git a/docs/content/guides/rows/row-height/row-height.md b/docs/content/guides/rows/row-height/row-height.md
index 8a2626af4c..289e5cbc51 100644
--- a/docs/content/guides/rows/row-height/row-height.md
+++ b/docs/content/guides/rows/row-height/row-height.md
@@ -362,7 +362,7 @@ When the [`AutoRowSize`](@/api/autoRowSize.md) plugin is enabled and you change

 - [autoRowSize](@/api/options.md#autorowsize)
 - [manualRowResize](@/api/options.md#manualrowresize)
-- [minRowHeights](@/api/options.md#minRowHeights)
+- [minRowHeights](@/api/options.md#minrowheights)
 - [textEllipsis](@/api/options.md#textellipsis)
 - [wordWrap](@/api/options.md#wordwrap)

diff --git a/docs/content/guides/styling/themes/themes.md b/docs/content/guides/styling/themes/themes.md
index adf984f536..c9f7b9b683 100644
--- a/docs/content/guides/styling/themes/themes.md
+++ b/docs/content/guides/styling/themes/themes.md
@@ -443,6 +443,8 @@ const customTheme = registerTheme('custom-theme', mainTheme);

 To start from another preset, import `classicTheme` or `horizonTheme` instead. Your theme keeps the density and icons of the preset: `main` uses the `'default'` density, `classic` uses `'compact'`, and `horizon` uses `'comfortable'`.

+If you publish a theme library that re-exports a preset and generates declaration files, see [Re-export a theme preset](@/guides/tools-and-building/typescript-types/typescript-types.md#re-export-a-theme-preset).
+
 ### Override values with `params()`

 Call `params()` to override only the colors and tokens you need. The values you pass are merged into your theme. `params()` returns the theme, so you can chain `setColorScheme()` and `setDensityType()` after it:
diff --git a/docs/content/guides/tools-and-building/typescript-types/typescript-types.md b/docs/content/guides/tools-and-building/typescript-types/typescript-types.md
index 7db46f7ad1..5de4eace76 100644
--- a/docs/content/guides/tools-and-building/typescript-types/typescript-types.md
+++ b/docs/content/guides/tools-and-building/typescript-types/typescript-types.md
@@ -200,7 +200,7 @@ function listHooks(hooks: HooksRegistry): string[] {

 ### Theme types

-These types are relevant when you use the [theming API](@/api/options.md#themeName) or build a custom theme.
+These types are relevant when you use the [theming API](@/api/options.md#themename) or build a custom theme.

 | Type | Description |
 | --- | --- |
@@ -218,6 +218,20 @@ These types are relevant when you use the [theming API](@/api/options.md#themeNa
 | `ThemeTokensConfig` | The full token map used inside a `ThemeConfig`. |
 | `BaseTheme` | The base theme object extended by all built-in themes. |

+#### Re-export a theme preset
+
+If you publish a theme library, you may re-export a preset from `handsontable/themes/static/variables` as is:
+
+```typescript
+import tokensMain from 'handsontable/themes/static/variables/tokens/main';
+
+export const tokens = tokensMain;
+```
+
+With `declaration: true`, TypeScript writes the type of `tokens` into your declaration file, so it has to name types such as `ThemeTokensConfig`, `TokenKey`, and `ThemeTokenValue`. Those types live in the `handsontable/themes/types` subpath. Before 19.0, that subpath wasn't importable, and the build failed with `TS2742` on TypeScript 5.1, or with `TS2883` on TypeScript 5.9 and later. From 19.0, the build works without a type annotation.
+
+You can import the same types from `handsontable/themes/types` when you annotate your own theme objects. `handsontable/themes` exports them too.
+
 ### Overlay type

 | Type | Description |
diff --git a/docs/content/guides/upgrade-and-migration/migrating-from-11.1-to-12.0/migrating-from-11.1-to-12.0.md b/docs/content/guides/upgrade-and-migration/migrating-from-11.1-to-12.0/migrating-from-11.1-to-12.0.md
index 6bbb88df5d..d785ca3e76 100644
--- a/docs/content/guides/upgrade-and-migration/migrating-from-11.1-to-12.0/migrating-from-11.1-to-12.0.md
+++ b/docs/content/guides/upgrade-and-migration/migrating-from-11.1-to-12.0/migrating-from-11.1-to-12.0.md
@@ -41,7 +41,7 @@ Each [`updateSettings()`](@/api/core.md#updatesettings) call with the [`data`](@

 If you need to reset your index mapper information and configuration options  along with updating your [`data`](@/api/options.md#data):

-- Instead of passing the [`data`](@/api/options.md#data) option to the [`updateSettings()`](@/api/core.md#updatesettings) method, run [`loadData()`](@/api/core.md#loadData) and provide the new dataset as its argument:
+- Instead of passing the [`data`](@/api/options.md#data) option to the [`updateSettings()`](@/api/core.md#updatesettings) method, run [`loadData()`](@/api/core.md#loaddata) and provide the new dataset as its argument:

 ```js
 // Handsontable 12.0: this doesn't reset your configuration options
@@ -61,7 +61,7 @@ hotInstance.loadData(newDataset);

 Updating your [`data`](@/api/options.md#data) through a component's property no longer resets your [index mapper](@/api/indexMapper.md) information and [configuration options](@/guides/configuration/configuration-options/configuration-options.md).

-If you still want to reset the states when replacing [`data`](@/api/options.md#data), call the [`loadData()`](@/api/core.md#loadData) method, referencing the Handsontable instance from the component:
+If you still want to reset the states when replacing [`data`](@/api/options.md#data), call the [`loadData()`](@/api/core.md#loaddata) method, referencing the Handsontable instance from the component:

 ```jsx
 import { useRef } from 'react';
@@ -88,7 +88,7 @@ To learn more about referencing the Handsontable instance, see the [Instance met

 Updating your [`data`](@/api/options.md#data) through a component property no longer resets your index mapper information and configuration options.

-To replace [`data`](@/api/options.md#data) and reset the states, call the [`loadData()`](@/api/core.md#loadData) method (the same way as above), referencing the Handsontable instance from the component.
+To replace [`data`](@/api/options.md#data) and reset the states, call the [`loadData()`](@/api/core.md#loaddata) method (the same way as above), referencing the Handsontable instance from the component.

 Read more on referencing the Handsontable instance:
 - [Referencing the Handsontable instance in Angular](@/angular/guides/getting-started/angular-hot-instance/angular-hot-instance.md)
diff --git a/examples/next/docs/js/accessibility/index.html b/examples/next/docs/js/accessibility/index.html
index bbfabe44c4..9bb31dd24e 100644
--- a/examples/next/docs/js/accessibility/index.html
+++ b/examples/next/docs/js/accessibility/index.html
@@ -26,7 +26,7 @@
             Enable navigation with the Tab key
           </label>
           <a
-            href="https://handsontable.com/docs/javascript-data-grid/api/options/#tabNavigation"
+            href="https://handsontable.com/docs/javascript-data-grid/api/options/#tabnavigation"
             target="_blank"
             class="external-link"
             rel="noopener noreferrer"
@@ -114,7 +114,7 @@
             Enable cells virtualization
           </label>
           <a
-            href="https://handsontable.com/docs/javascript-data-grid/api/options/#renderAllRows"
+            href="https://handsontable.com/docs/javascript-data-grid/api/options/#renderallrows"
             target="_blank"
             class="external-link"
             rel="noopener noreferrer"
diff --git a/examples/next/docs/react-wrapper/accessibility/src/DemoOptions.tsx b/examples/next/docs/react-wrapper/accessibility/src/DemoOptions.tsx
index 5fb6c7b96d..f18f92ed8e 100644
--- a/examples/next/docs/react-wrapper/accessibility/src/DemoOptions.tsx
+++ b/examples/next/docs/react-wrapper/accessibility/src/DemoOptions.tsx
@@ -99,7 +99,7 @@ function DemoOptions({
               Enable navigation with the Tab key
             </label>
             <a
-              href="https://handsontable.com/docs/react-data-grid/api/options/#tabNavigation"
+              href="https://handsontable.com/docs/react-data-grid/api/options/#tabnavigation"
               target="_blank"
               className="external-link"
               rel="noopener noreferrer"
@@ -193,7 +193,7 @@ function DemoOptions({
               Enable cells virtualization
             </label>
             <a
-              href="https://handsontable.com/docs/react-data-grid/api/options/#renderAllRows"
+              href="https://handsontable.com/docs/react-data-grid/api/options/#renderallrows"
               target="_blank"
               className="external-link"
               rel="noopener noreferrer"
diff --git a/handsontable/src/core/hooks/constants.ts b/handsontable/src/core/hooks/constants.ts
index 583f84bf9d..14a2e73655 100644
--- a/handsontable/src/core/hooks/constants.ts
+++ b/handsontable/src/core/hooks/constants.ts
@@ -41,6 +41,7 @@
  *     });
  *   }}
  * />
+ * ```
  * :::
  *
  * ::: only-for angular
@@ -119,6 +120,7 @@
  *     // function body - will only run for first instance
  *   }
  * });
+ * ```
  * :::
  * ...
  */
diff --git a/handsontable/src/dataMap/metaManager/metaSchema.ts b/handsontable/src/dataMap/metaManager/metaSchema.ts
index 7e1060bbc3..e2146d9696 100644
--- a/handsontable/src/dataMap/metaManager/metaSchema.ts
+++ b/handsontable/src/dataMap/metaManager/metaSchema.ts
@@ -3914,6 +3914,7 @@ export default (): Record<string, unknown> => {
      *
      * // keep the selected items in the dropdown
      * filterSelectedItems: false,
+     * ```
      */
     filterSelectedItems: true,

diff --git a/handsontable/test/__tests__/jsdocCodeFences.unit.js b/handsontable/test/__tests__/jsdocCodeFences.unit.js
new file mode 100644
index 0000000000..9ffe575908
--- /dev/null
+++ b/handsontable/test/__tests__/jsdocCodeFences.unit.js
@@ -0,0 +1,184 @@
+import { readdirSync, readFileSync } from 'fs';
+import { join, relative, resolve, sep } from 'path';
+
+/**
+ * The API reference is generated from the JSDoc blocks of the core source. A fenced code block
+ * that is opened in a block but never closed swallows everything the generator emits after it:
+ * the next option or method renders inside the code block, so it gets no heading and no anchor.
+ * That broke the `filterValueComparator` section of the API reference in 19.0.0-rc7, and swallowed
+ * another heading in 18.1.3.
+ *
+ * A fence line that carries a language (```` ```js ````) opens a block. A bare fence line closes the
+ * open one. Counting fence lines is not enough: in Markdown a fence line with a language inside an
+ * open block is content, not a closer, so a block with an unclosed ```` ```jsx ```` followed by a
+ * ```` ```ts ```` still holds an even number of fence lines and swallows the second example.
+ * The scan therefore walks each block line by line.
+ */
+
+const REPO_ROOT = resolve(__dirname, '../..', '..');
+const CORE_SRC = 'handsontable/src';
+
+// Test code and test helpers are not API documentation.
+const SKIPPED_DIR_NAMES = ['__tests__', 'test', 'node_modules'];
+
+// A comment line that starts with a code fence, as in ` * ```js` or ` * ```` ` (the info string is captured).
+const FENCE_LINE = /^\s*\*\s*```(\S*)/;
+// A JSDoc block, from its opening `/**` to the first closing `*/`.
+const JSDOC_BLOCK = /\/\*\*[\s\S]*?\*\//g;
+
+/**
+ * Lists the source files under `dir`, recursively. Test folders and declaration files are skipped.
+ *
+ * @param {string} dir Directory to walk, relative to the repository root.
+ * @returns {string[]} Repository-relative paths, using forward slashes.
+ */
+function walk(dir) {
+  const found = [];
+  const queue = [resolve(REPO_ROOT, dir)];
+
+  while (queue.length > 0) {
+    const current = queue.pop();
+
+    for (const entry of readdirSync(current, { withFileTypes: true })) {
+      const path = join(current, entry.name);
+
+      if (entry.isDirectory()) {
+        if (!SKIPPED_DIR_NAMES.includes(entry.name)) {
+          queue.push(path);
+        }
+      } else if (/\.(ts|js)$/.test(entry.name) && !entry.name.endsWith('.d.ts')) {
+        found.push(relative(REPO_ROOT, path).split(sep).join('/'));
+      }
+    }
+  }
+
+  return found;
+}
+
+/**
+ * Describes what is wrong with the fences of one JSDoc block.
+ *
+ * @param {string} block The text of one JSDoc block.
+ * @param {number} firstLine The line of the file where the block starts.
+ * @returns {{ line: number, text: string }|null} The file line of the first defect and what is wrong,
+ * or `null` when every fence closes.
+ */
+function describeFenceDefect(block, firstLine) {
+  const lines = block.split('\n');
+  let openedAt = -1;
+
+  for (let index = 0; index < lines.length; index++) {
+    const match = FENCE_LINE.exec(lines[index]);
+
+    if (match) {
+      if (openedAt === -1) {
+        openedAt = index;
+      } else if (match[1] !== '') {
+        return {
+          line: firstLine + index,
+          text: `\`\`\`${match[1]} sits inside the fence opened at line ${firstLine + openedAt}`,
+        };
+      } else {
+        openedAt = -1;
+      }
+    }
+  }
+
+  return openedAt === -1 ? null : { line: firstLine + openedAt, text: 'this fence is never closed' };
+}
+
+/**
+ * Finds the JSDoc blocks of one source text whose code fences do not close.
+ *
+ * @param {string} source The source text.
+ * @param {string} file The name to report the finding under.
+ * @returns {string[]} Findings as `<file>:<line>: <defect>`, where the line is the fence's own line.
+ */
+function findFenceDefectsInSource(source, file) {
+  const findings = [];
+
+  for (const match of source.matchAll(JSDOC_BLOCK)) {
+    const firstLine = source.slice(0, match.index).split('\n').length;
+    const defect = describeFenceDefect(match[0], firstLine);
+
+    if (defect !== null) {
+      findings.push(`${file}:${defect.line}: ${defect.text}`);
+    }
+  }
+
+  return findings;
+}
+
+/**
+ * Finds the JSDoc blocks whose code fences do not close, in the given files.
+ *
+ * @param {string[]} files Repository-relative paths to scan.
+ * @returns {string[]} Findings, empty when every fence closes.
+ */
+function findFenceDefects(files) {
+  return files.flatMap(file => findFenceDefectsInSource(readFileSync(resolve(REPO_ROOT, file), 'utf8'), file));
+}
+
+describe('JSDoc code fences', () => {
+  it('should close every fenced code block in the core JSDoc comments', () => {
+    const files = walk(CORE_SRC);
+
+    expect(files.length).toBeGreaterThan(500);
+    expect(findFenceDefects(files)).toEqual([]);
+  });
+
+  it('should report a block that opens a fence and never closes it', () => {
+    const source = [
+      'const first = 1;',
+      '',
+      '/**',
+      ' * Description.',
+      ' *',
+      ' * @example',
+      ' * ```js',
+      ' * option: true,',
+      ' */',
+      'option: true,',
+    ].join('\n');
+
+    expect(findFenceDefectsInSource(source, 'sample.ts')).toEqual([
+      'sample.ts:7: this fence is never closed',
+    ]);
+  });
+
+  it('should report a fence with a language that sits inside an unclosed fence', () => {
+    const source = [
+      '/**',
+      ' * ```jsx',
+      ' * <HotTable />',
+      ' * ```ts',
+      ' * settings = {};',
+      ' * ```',
+      ' * ```html',
+      ' * <hot-table />',
+      ' * ```',
+      ' */',
+    ].join('\n');
+
+    expect(findFenceDefectsInSource(source, 'sample.ts')).toEqual([
+      'sample.ts:4: ```ts sits inside the fence opened at line 2',
+    ]);
+  });
+
+  it('should accept blocks that close every fence', () => {
+    const source = [
+      '/**',
+      ' * @example',
+      ' * ```js',
+      ' * option: true,',
+      ' * ```',
+      ' *',
+      ' * ```ts',
+      ' * option = true;',
+      ' * ```',
+      ' */',
+    ].join('\n');
+
+    expect(findFenceDefectsInSource(source, 'sample.ts')).toEqual([]);
+  });
+});