extract_sections#

dscat.docs.extract_sections(md_path, pattern, context=3)[source]#

Return windows of lines around each case-insensitive match of pattern.

Each match contributes the lines within context lines on either side; overlapping windows are merged.

Parameters:
  • md_path (pathlib.Path) – Markdown file to scan.

  • pattern (str) – Regular expression matched against each line, case-insensitively.

  • context (int, default 3) – Number of lines to include on each side of a match.

Returns:

One newline-joined block of text per merged window.

Return type:

list of str