Skip to content

enhancement(linting): improve regex patterns in Validate-MarkdownFrontmatter #33

@WilliamBerryiii

Description

@WilliamBerryiii

Issue Description

The regex patterns for HTML comments and markdown formatting in Validate-MarkdownFrontmatter.ps1 have limitations and could be enhanced.

File: scripts/linting/Validate-MarkdownFrontmatter.ps1
Line: 179

Problem

Current patterns:

$htmlCommentPattern = '<!--.*?-->'
$markdownFormatPattern = '(\*\*|__)(.*?)\1|(\*|_)(.*?)\3'

Limitations:

  • HTML comment pattern doesn't handle multiline comments properly
  • Markdown format pattern has backreference issues and doesn't cover all markdown syntax

Suggested Enhancement

$htmlCommentPattern = '(?s)<!--.*?-->'
$markdownFormatPattern = '(\*\*|__)([^*_]+?)\1|(\*|_)([^*_]+?)\3|\([^\`]+?\)'
  • (?s) enables multiline matching for HTML comments
  • Non-greedy character classes prevent over-matching
  • Added inline code pattern

Impact

  • Severity: Low
  • Enhancement to improve validation accuracy
  • Not blocking current functionality

Source

Identified in PR #26 code review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlintingLinting rules and validationpriority-4Low priority, when time permitsscriptsPowerShell, Bash, or Python scripts

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions