1function Get-ParagraphText([string]$html) {
2 $plain = [regex]::Replace($html, '<[^>]*>', '')
3 $plain = [regex]::Replace($plain, '&#(?:x([0-9a-fA-F]+)|([0-9]+));', {
4 param($match)
5 $value = if ($match.Groups[1].Success) {
6 [Convert]::ToInt32($match.Groups[1].Value, 16)
7 } else { [int]$match.Groups[2].Value }
8 # The Win7 framework leaves supplementary numeric entities undecoded.
9 if ($value -gt 0xffff -and $value -le 0x10ffff) { [char]::ConvertFromUtf32($value) }
10 else { $match.Value }
11 })
12 [Net.WebUtility]::HtmlDecode($plain)
13}