Skip to content

Instantly share code, notes, and snippets.

@StartAutomating
Created October 5, 2025 21:39
Show Gist options
  • Select an option

  • Save StartAutomating/3c2b9bb95644d316618833c7675b2846 to your computer and use it in GitHub Desktop.

Select an option

Save StartAutomating/3c2b9bb95644d316618833c7675b2846 to your computer and use it in GitHub Desktop.

Revisions

  1. StartAutomating created this gist Oct 5, 2025.
    25 changes: 25 additions & 0 deletions LooksLikeMarkdown.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    filter looksLikeMarkdown {
    if (
    # If it's got a markdown-like link
    $_ -match '\[[^\]]+\]\(' -or
    # Or any of the lines start with markdown special characters
    $_ -split '(?>\r\n|\n)' -match '\s{0,3}[\#*~`]'
    ) {
    # it's probably markdown
    $_
    }
    }

    # does not look like markdown
    "hello" | looksLikeMarkdown
    # does not look like markdown
    "<h1>hello world</h1>" | looksLikeMarkdown


    # Everything from here on down looks like markdown
    "[hello world](https://example.com)" | looksLikeMarkdown
    "# hello world" | looksLikeMarkdown
    "* one thing" | looksLikeMarkdown
    "~~~PowerShell
    'hello world'
    ~~~" | looksLikeMarkdown