-
Notifications
You must be signed in to change notification settings - Fork 5
/
WhatsNewtoMarkdown.ps1
49 lines (44 loc) · 2.29 KB
/
WhatsNewtoMarkdown.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# This PowerShell script retrieves the What's New page from Docs, puts it in a C:\Scripts folder as a html file and then converts it to a Markdown file (WhatsNew.md)so it can be imported into a Microsoft Sentinel Workbook.
# Install MarkdownPrince module if not already installed
Install-Module -Name MarkdownPrince -AllowClobber -Force
$Webcontent = Invoke-WebRequest -Uri 'https://learn.microsoft.com/en-us/azure/sentinel/whats-new'
$Webcontent.Content | Out-File -FilePath C:\Scripts\WhatsNew.html
$RulesBefore = @(
'(?ms)<div id="logo" class="clearfix">(.*?)<\/div>'
'(?ms)<a class="pTitle clearfix" href="https://learn.microsoft.com/en-us/azure/sentinel/whats-new">(.*?)<\/a>'
'(?ms)<ul class="meta">(.*?)<\/ul>'
'(?ms)<title>(.*?)<\/title>'
'(?ms)<div class="left clearfix">(.*?)<\/div>'
'(?ms)<div class="right clearfix">(.*?)<\/div>'
'(?ms)<div id="icl_lang_sel_widget-3" class="widget sidebox widget_icl_lang_sel_widget">(.*?)<\/div>'
'(?ms)<div id="pageTitle" class="clearfix">(.*?)<\/div>'
'(?ms)<nav id="menu" class="cartfalse">(.*?)<\/nav>'
'(?ms)<nav id="breadcrumb" itemprop="breadcrumb">(.*?)<\/nav>'
'(?ms)<div class="wpml-ls-statics-footer wpml-ls wpml-ls-legacy-list-horizontal">(.*?)<\/div>'
'(?ms)<div id="oldie">(.*?)<\/div>'
'(?ms)<footer id="footer1" class="clearfix">(.*?)<\/footer>'
'(?ms)<footer id="footer2" class="clearfix">(.*?)<\/footer>'
'(?ms)<pre class="hidden">(.*?)</pre>'
# remove tags
'(?ms)<span class="meta-holder">(.*)<\/span>'
# we shouldn't have to play with script at all but seems to be a bug in reversemarkdown library
"(?ms)<script type='text/javascript' id='wp-util-js-extra'>(.*)<\/script>"
'(?ms)<script id="wp-util-js-extra">(.*)<\/script>'
)
$RulesAfter = @(
'<br>'
)
$Splat = @{
#Content = $BlogContent.Content
Path = "C:\Scripts\WhatsNew.html"
DestinationPath = "C:\Scripts\WhatsNew.md"
UnknownTags = 'Bypass'
GithubFlavored = $true
RemoveComments = $true
SmartHrefHandling = $true
RulesBefore = $RulesBefore
RulesAfter = $RulesAfter
DefaultCodeBlockLanguage = 'powershell'
Format = $false
}
ConvertFrom-HTMLToMarkdown @Splat