Change help headings for WCAG 2.0

Created on 12 January 2024, 12 months ago
Updated 29 January 2024, 11 months ago

Problem/Motivation

When hook_help() pages are output, they go on a page such as admin/help/link. The page structure has an H1 at the top for the page title, and then in the main content region, the next header is the H3 saying "About". There is no H2 on the page, except in the Toolbar area, which is outside the hierarchy of the main content region.

However, in order to follow best practices for accessibility, Techniques for WCAG 2.0: organizing a Page Using headings, sections should begin with an h2 and subsections an h3.

To facilitate navigation and understanding of overall document structure, authors should use headings that are properly nested (e.g., h1 followed by h2, h2 followed by h2 or h3, h3 followed by h3 or h4, etc.).

Proposed resolution

Update headings to conform to WCAG 2.0: organizing a Page Using headings

The change can be done with this script provided by andypost.

core$ cat help.sh 
#!/bin/bash

# Path to the Drupal root directory.
DRUPAL_ROOT="/path/to/drupal"
DRUPAL_ROOT="."

# Function name pattern of hook implementations for hook_help.
HOOK_HELP_PATTERN='function .*_help'

# Find all files in the Drupal root directory.
find "$DRUPAL_ROOT" -type f -name "*.module" | while read -r file; do
    # Check if the file contains the implementation of hook_help.
    if grep -q "$HOOK_HELP_PATTERN" "$file"; then
        # Use sed to replace <h3> with <h2> in the hook_help implementation.
        sed -i "/${HOOK_HELP_PATTERN}/,/^}/{s/<h3>/<h2>/g; s/<\\/h3>/<\\/h2>/g;}" "$file"
        echo "Updated $file"
    fi
done

echo "Done replacing <h3> tags with <h2> in hook_help implementations."

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

10.2

Component
Help 

Last updated 14 days ago

No maintainer
Created by

🇳🇿New Zealand quietone

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024