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

Issue fork drupal-3414263

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

quietone created an issue. See original summary.

quietone credited andypost.

quietone’s picture

Status: Active » Needs review

I used the script to make the changes.

Adding credit for andypost for the script.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Another issue is RTBC as well

The changes are scriptable so could be reused by contrib code

  • lauriii committed 1e8ae69e on 11.x
    Issue #3414263 by quietone, andypost: Change help headings for WCAG 2.0
    

  • lauriii committed 379968c4 on 10.2.x
    Issue #3414263 by quietone, andypost: Change help headings for WCAG 2.0...

lauriii’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 1e8ae69 and pushed to 11.x. Cherry-picked to 10.2.x as a non-disruptive a11y bug fix. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.