Skip to content

Commit cb15701

Browse files
committed
⬆️ Upgrade to .NET 10 and ReverseMarkdown 6.1
1 parent 8422604 commit cb15701

8 files changed

Lines changed: 245 additions & 252 deletions

HtmlToMarkdown.csproj

Lines changed: 0 additions & 24 deletions
This file was deleted.

HtmlToMarkdown.sln

Lines changed: 0 additions & 40 deletions
This file was deleted.

HtmlToMarkdown.slnx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Solution>
2+
<Configurations>
3+
<Platform Name="Any CPU" />
4+
<Platform Name="x64" />
5+
<Platform Name="x86" />
6+
</Configurations>
7+
<Folder Name="/src/">
8+
<Project Path="src/HtmlToMarkdown/HtmlToMarkdown.fsproj" />
9+
</Folder>
10+
</Solution>

docs/Convert-HtmlToMarkdown.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Converts HTML to Markdown.
1616
Convert-HtmlToMarkdown -Html <String> [-DefaultCodeBlockLanguage <String>] [-GithubFlavored]
1717
[-ListBulletChar <Char>] [-RemoveComments] [-SmartHrefHandling] [-UnknownTags <UnknownTagsOption>]
1818
[-PassThroughTags <String[]>] [-WhitelistUriSchemes <String[]>]
19-
[-TableWithoutHeaderRowHandling <TableWithoutHeaderRowHandlingOption>] [<CommonParameters>]
19+
[-TableWithoutHeaderRowHandling <TableWithoutHeaderRowHandlingOption>] [-ProgressAction <ActionPreference>]
20+
[<CommonParameters>]
2021
```
2122

2223
## DESCRIPTION
@@ -203,6 +204,21 @@ Accept pipeline input: False
203204
Accept wildcard characters: False
204205
```
205206
207+
### -ProgressAction
208+
{{ Fill ProgressAction Description }}
209+
210+
```yaml
211+
Type: ActionPreference
212+
Parameter Sets: (All)
213+
Aliases: proga
214+
215+
Required: False
216+
Position: Named
217+
Default value: None
218+
Accept pipeline input: False
219+
Accept wildcard characters: False
220+
```
221+
206222
### CommonParameters
207223
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
208224
Lines changed: 91 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,91 @@
1-
namespace HtmlToMarkdown
2-
3-
open System.Management.Automation
4-
5-
open ReverseMarkdown
6-
7-
/// Converts HTML to Markdown.
8-
[<Cmdlet(VerbsData.Convert, "HtmlToMarkdown")>]
9-
[<OutputType(typeof<string>)>]
10-
[<Alias("Convert-HtmlToCommonMark")>]
11-
type ConvertHtmlToMarkdownCommand () =
12-
inherit PSCmdlet ()
13-
14-
/// HTML to convert.
15-
[<Parameter(Mandatory=true,ValueFromPipeline=true,ValueFromPipelineByPropertyName=true)>]
16-
[<ValidateNotNullOrEmpty>]
17-
[<Alias("InputObject","OuterHtml")>]
18-
member val Html : string = null with get, set
19-
20-
/// Option to set the default code block language for Github style markdown if class based language markers are not available.
21-
[<Parameter>]
22-
[<ValidateNotNullOrEmpty>]
23-
[<Alias("CodeDefault")>]
24-
member val DefaultCodeBlockLanguage : string = null with get, set
25-
26-
/// Github style markdown for br, pre and table.
27-
[<Parameter>]
28-
[<Alias("GFM")>]
29-
member val GithubFlavored : SwitchParameter = SwitchParameter false with get, set
30-
31-
/// Sets the bullet character to use for unordered lists.
32-
[<Parameter>]
33-
[<Alias("Bullets")>]
34-
member val ListBulletChar : char = '-' with get, set
35-
36-
/// Remove comment tags with text.
37-
[<Parameter>]
38-
[<Alias("StripComments")>]
39-
member val RemoveComments : SwitchParameter = SwitchParameter false with get, set
40-
41-
/// Outputs link as auto-linking text (not an explicit link) when the text matches the link.
42-
[<Parameter>]
43-
[<Alias("AutoLink")>]
44-
member val SmartHrefHandling : SwitchParameter = SwitchParameter false with get, set
45-
46-
/// What to do with unknown tags: PassThrough includes it as is, Drop removes it, Bypass ignores it, and Raise throws an exception.
47-
[<Parameter>]
48-
[<Alias("UnknownElements")>]
49-
member val UnknownTags : Config.UnknownTagsOption = Config.UnknownTagsOption.PassThrough with get, set
50-
51-
/// Pass a list of tags to pass through as-is without any processing.
52-
[<Parameter>]
53-
[<ValidateNotNullOrEmpty>]
54-
[<Alias("PassThroughElements","KeepTags","KeepElements")>]
55-
member val PassThroughTags : string[] = Array.empty with get, set
56-
57-
/// Specify which schemes (without trailing colon) are to be allowed for links and images. Empty string allows unknown schemes.
58-
[<Parameter>]
59-
[<Alias("AllowlistUriSchemes")>]
60-
member val WhitelistUriSchemes : string[] = Array.empty with get, set
61-
62-
/// What to do about tables without a header row. Default: first row will be used as header row. EmptyRow: an empty header row is created.
63-
[<Parameter>]
64-
[<Alias("TableHeaderDefault")>]
65-
member val TableWithoutHeaderRowHandling : Config.TableWithoutHeaderRowHandlingOption =
66-
Config.TableWithoutHeaderRowHandlingOption.Default with get, set
67-
68-
member val Converter : Converter = null with get, set
69-
70-
// optional: setup before pipeline input starts (e.g. Name is set, InputObject is not)
71-
override x.BeginProcessing () =
72-
base.BeginProcessing ()
73-
x.Converter
74-
<- Converter
75-
<| Config(DefaultCodeBlockLanguage = x.DefaultCodeBlockLanguage,
76-
GithubFlavored = x.GithubFlavored,
77-
ListBulletChar = x.ListBulletChar,
78-
RemoveComments = x.RemoveComments,
79-
SmartHrefHandling = x.SmartHrefHandling,
80-
UnknownTags = x.UnknownTags,
81-
PassThroughTags = x.PassThroughTags,
82-
WhitelistUriSchemes = x.WhitelistUriSchemes,
83-
TableWithoutHeaderRowHandling = x.TableWithoutHeaderRowHandling)
84-
85-
// optional: handle each pipeline value (e.g. InputObject)
86-
override x.ProcessRecord () =
87-
base.ProcessRecord ()
88-
x.Converter.Convert(x.Html) |> x.WriteObject
89-
90-
// optional: finish after all pipeline input
91-
override x.EndProcessing () =
92-
base.EndProcessing ()
1+
namespace HtmlToMarkdown
2+
3+
open System.Management.Automation
4+
5+
open ReverseMarkdown
6+
7+
/// Converts HTML to Markdown.
8+
[<Cmdlet(VerbsData.Convert, "HtmlToMarkdown")>]
9+
[<OutputType(typeof<string>)>]
10+
[<Alias("Convert-HtmlToCommonMark")>]
11+
type ConvertHtmlToMarkdownCommand () =
12+
inherit PSCmdlet ()
13+
14+
/// HTML to convert.
15+
[<Parameter(Mandatory=true,ValueFromPipeline=true,ValueFromPipelineByPropertyName=true)>]
16+
[<ValidateNotNullOrEmpty>]
17+
[<Alias("InputObject","OuterHtml")>]
18+
member val Html : string = null with get, set
19+
20+
/// Option to set the default code block language for Github style markdown if class based language markers are not available.
21+
[<Parameter>]
22+
[<ValidateNotNullOrEmpty>]
23+
[<Alias("CodeDefault")>]
24+
member val DefaultCodeBlockLanguage : string = null with get, set
25+
26+
/// Github style markdown for br, pre and table.
27+
[<Parameter>]
28+
[<Alias("GFM")>]
29+
member val GithubFlavored : SwitchParameter = SwitchParameter false with get, set
30+
31+
/// Sets the bullet character to use for unordered lists.
32+
[<Parameter>]
33+
[<Alias("Bullets")>]
34+
member val ListBulletChar : char = '-' with get, set
35+
36+
/// Remove comment tags with text.
37+
[<Parameter>]
38+
[<Alias("StripComments")>]
39+
member val RemoveComments : SwitchParameter = SwitchParameter false with get, set
40+
41+
/// Outputs link as auto-linking text (not an explicit link) when the text matches the link.
42+
[<Parameter>]
43+
[<Alias("AutoLink")>]
44+
member val SmartHrefHandling : SwitchParameter = SwitchParameter false with get, set
45+
46+
/// What to do with unknown tags: PassThrough includes it as is, Drop removes it, Bypass ignores it, and Raise throws an exception.
47+
[<Parameter>]
48+
[<Alias("UnknownElements")>]
49+
member val UnknownTags : Config.UnknownTagsOption = Config.UnknownTagsOption.PassThrough with get, set
50+
51+
/// Pass a list of tags to pass through as-is without any processing.
52+
[<Parameter>]
53+
[<ValidateNotNullOrEmpty>]
54+
[<Alias("PassThroughElements","KeepTags","KeepElements")>]
55+
member val PassThroughTags : string[] = Array.empty with get, set
56+
57+
/// Specify which schemes (without trailing colon) are to be allowed for links and images. Empty string allows unknown schemes.
58+
[<Parameter>]
59+
[<Alias("AllowlistUriSchemes")>]
60+
member val WhitelistUriSchemes : string[] = Array.empty with get, set
61+
62+
/// What to do about tables without a header row. Default: first row will be used as header row. EmptyRow: an empty header row is created.
63+
[<Parameter>]
64+
[<Alias("TableHeaderDefault")>]
65+
member val TableWithoutHeaderRowHandling : Config.TableWithoutHeaderRowHandlingOption =
66+
Config.TableWithoutHeaderRowHandlingOption.Default with get, set
67+
68+
member val Converter : Converter = null with get, set
69+
70+
// optional: setup before pipeline input starts (e.g. Name is set, InputObject is not)
71+
override x.BeginProcessing () =
72+
base.BeginProcessing ()
73+
let cfg = Config(DefaultCodeBlockLanguage = x.DefaultCodeBlockLanguage,
74+
GithubFlavored = x.GithubFlavored,
75+
ListBulletChar = x.ListBulletChar,
76+
RemoveComments = x.RemoveComments,
77+
SmartHrefHandling = x.SmartHrefHandling,
78+
UnknownTags = x.UnknownTags,
79+
TableWithoutHeaderRowHandling = x.TableWithoutHeaderRowHandling)
80+
Array.iter (cfg.PassThroughTags.Add >> ignore) x.PassThroughTags
81+
Array.iter (cfg.WhitelistUriSchemes.Add >> ignore) x.WhitelistUriSchemes
82+
x.Converter <- Converter <| cfg
83+
84+
// optional: handle each pipeline value (e.g. InputObject)
85+
override x.ProcessRecord () =
86+
base.ProcessRecord ()
87+
x.Converter.Convert(x.Html) |> x.WriteObject
88+
89+
// optional: finish after all pipeline input
90+
override x.EndProcessing () =
91+
base.EndProcessing ()

src/HtmlToMarkdown/HtmlToMarkdown.dll-Help.xml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@
142142
</dev:type>
143143
<dev:defaultValue>None</dev:defaultValue>
144144
</command:parameter>
145+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
146+
<maml:name>ProgressAction</maml:name>
147+
<maml:description>
148+
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
149+
</maml:description>
150+
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
151+
<dev:type>
152+
<maml:name>ActionPreference</maml:name>
153+
<maml:uri />
154+
</dev:type>
155+
<dev:defaultValue>None</dev:defaultValue>
156+
</command:parameter>
145157
</command:syntaxItem>
146158
</command:syntax>
147159
<command:parameters>
@@ -265,6 +277,18 @@
265277
</dev:type>
266278
<dev:defaultValue>None</dev:defaultValue>
267279
</command:parameter>
280+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="proga">
281+
<maml:name>ProgressAction</maml:name>
282+
<maml:description>
283+
<maml:para>{{ Fill ProgressAction Description }}</maml:para>
284+
</maml:description>
285+
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
286+
<dev:type>
287+
<maml:name>ActionPreference</maml:name>
288+
<maml:uri />
289+
</dev:type>
290+
<dev:defaultValue>None</dev:defaultValue>
291+
</command:parameter>
268292
</command:parameters>
269293
<command:inputTypes>
270294
<command:inputType>
@@ -294,7 +318,7 @@
294318
<command:examples>
295319
<command:example>
296320
<maml:title>-------------------------- Example 1 --------------------------</maml:title>
297-
<dev:code>PS C:\&gt; '&lt;h1&gt;On Board&lt;/h1&gt;&lt;ul&gt;&lt;li&gt;Ford&lt;li&gt;Zaphod&lt;li&gt;Marvin&lt;/ul&gt;' |Convert-HtmlToMarkdown
321+
<dev:code>'&lt;h1&gt;On Board&lt;/h1&gt;&lt;ul&gt;&lt;li&gt;Ford&lt;li&gt;Zaphod&lt;li&gt;Marvin&lt;/ul&gt;' |Convert-HtmlToMarkdown
298322

299323
# On Board
300324

@@ -305,6 +329,18 @@
305329
<maml:para></maml:para>
306330
</dev:remarks>
307331
</command:example>
332+
<command:example>
333+
<maml:title>-------------------------- Example 2 --------------------------</maml:title>
334+
<dev:code>Invoke-RestMethod https://google.com/ |Convert-HtmlToCommonMark -UnknownTags Bypass
335+
336+
1. [Search](https://www.google.com/webhp?tab=ww)
337+
2. [Images](https://www.google.com/imghp?hl=en&amp;tab=wi)
338+
3. [Maps](https://maps.google.com/maps?hl=en&amp;tab=wl)
339+
...</dev:code>
340+
<dev:remarks>
341+
<maml:para></maml:para>
342+
</dev:remarks>
343+
</command:example>
308344
</command:examples>
309345
<command:relatedLinks />
310346
</command:command>

0 commit comments

Comments
 (0)