Skip to content

Instantly share code, notes, and snippets.

@StartAutomating
Created October 5, 2025 21:39
Show Gist options
  • Save StartAutomating/3c2b9bb95644d316618833c7675b2846 to your computer and use it in GitHub Desktop.
Save StartAutomating/3c2b9bb95644d316618833c7675b2846 to your computer and use it in GitHub Desktop.
Gist tell me if it looks like Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment