Module header_id_utils

Module header_id_utils 

Source
Expand description

Utilities for extracting custom header IDs from various Markdown flavors

This module supports multiple syntax formats for custom header IDs:

§Kramdown Format

  • {#custom-id} - Simple ID without colon
  • Example: # Header {#my-id}

§Python-markdown attr-list Format

  • {:#custom-id} - ID with colon, no spaces
  • {: #custom-id} - ID with colon and spaces
  • {: #custom-id .class} - ID with classes
  • {: #custom-id .class data="value"} - ID with full attributes
  • Example: # Header {: #my-id .highlight}

§Position Support

  • Inline: # Header {#id} (all formats)
  • Next-line: Jekyll/kramdown style where attr-list appears on the line after the header
    # Header
    {#next-line-id}

The module provides functions to detect and extract IDs from both inline and standalone (next-line) attr-list syntax.

Functions§

extract_header_id
Extract custom header ID from a line if present, returning clean text and ID
extract_standalone_attr_list_id
Extract ID from a standalone attr-list line
is_standalone_attr_list
Check if a line is a standalone attr-list (Jekyll/kramdown style)