Created
March 1, 2020 08:35
-
-
Save advanceboy/171c86848c0239f34f170f358708fc54 to your computer and use it in GitHub Desktop.
クリップボード内にある WordPress 用の記事の本文から、 CodeColorer プラグインのショートコードから Markdown のコードブロックへ、雑に置き換える PowerShell コード
This file contains 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
[regex]::Replace((Get-Clipboard -Raw), '\[([a-zA-Z]{1,14})(?: lang(?:uage)?="(.*?)")?\](.*?)\[/\1\]', { | |
param([System.Text.RegularExpressions.Match]$m); | |
switch ($m.Groups[1].Value) { | |
'cci' { | |
return '`' + [System.Web.HttpUtility]::HtmlDecode($m.Groups[3].Value) + '`' | |
} | |
{ 'code', 'cc' -contains $_ } { | |
return '```' + $m.Groups[2].Value + [System.Web.HttpUtility]::HtmlDecode($m.Groups[3].Value) + '```' | |
} | |
default { | |
return '```' + $m.Groups[1].Value + [System.Web.HttpUtility]::HtmlDecode($m.Groups[3].Value) + '```' | |
} | |
} | |
}, [System.Text.RegularExpressions.RegexOptions]::Singleline) | Set-Clipboard; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment