Created
October 5, 2025 21:39
-
-
Save StartAutomating/3c2b9bb95644d316618833c7675b2846 to your computer and use it in GitHub Desktop.
Gist tell me if it looks like Markdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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