@@ -17,6 +17,7 @@ Render markdown content on console to improve readability.
17
17
18
18
Markdown is a common authoring format used by the community.
19
19
There is no easy way in PowerShell to visualize a markdown document on console.
20
+ Since the PowerShell help is authored in markdown, these components will be used for rendering help content.
20
21
21
22
## Specification
22
23
@@ -25,8 +26,9 @@ This RFC proposes to use `VT100` escape sequences to render markdown content.
25
26
The ` Tokens ` property has the AST for the markdown document from ` markdig ` .
26
27
The ` Html ` property has the markdown document converted to ` HTML ` .
27
28
The ` VT100EncodedString ` property has the markdown documented with ` VT100 ` escape sequences.
28
- By default, the ` Tokens ` and ` Html ` properties will be populated.
29
+ By default, the ` Html ` property will be populated.
29
30
The ` VT100EncodedString ` property will be populated only when ` -AsVT100EncodedString ` is specified.
31
+ The ` Tokens ` property will be populated in all cases.
30
32
31
33
For converting strings to VT100 coded strings, we will be writing an extension to [ markdig] ( https://github.com/lunet-io/markdig ) .
32
34
The extension will insert VT100 escape sequences as appropriate.
@@ -52,11 +54,15 @@ ConvertFrom-Markdown [-InputObject] <psobject> [-AsVT100EncodedString] [<CommonP
52
54
53
55
There will be support for changing the colors for various elements using the ` Set-MarkdownOption ` cmdlet. To retrieve the current settings ` Get-MarkdownOption ` cmdlet can be used.
54
56
57
+ #### Output Type
58
+
59
+ The output type will be ` MarkdownInfo ` object with properties for ` Html ` , ` VT100EncodedString ` and ` Tokens ` .
60
+
55
61
### Specification for ` Set-MarkdownOption `
56
62
57
63
``` PowerShell
58
64
59
- Set-MarkdownOption [-Header1Color <ConsoleColor >] [-Header2Color <ConsoleColor >] [-Header3Color <ConsoleColor >] [-Header4Color <ConsoleColor >] [-Header5Color <ConsoleColor >] [-Header6Color <ConsoleColor >] [-CodeBlockForegroundColor <ConsoleColor >] [-CodeBlockBackgroundColor <ConsoleColor >] [-ImageAltTextForegroundColor <ConsoleColor >] [-LinkForegroundColor <ConsoleColor >] [-ItalicsForegroundColor <ConsoleColor >] [<CommonParameters>]
65
+ Set-MarkdownOption [-Header1Color <string >] [-Header2Color <string >] [-Header3Color <string >] [-Header4Color <string >] [-Header5Color <string >] [-Header6Color <string >] [-CodeBlockForegroundColor <string >] [-CodeBlockBackgroundColor <string >] [-ImageAltTextForegroundColor <string >] [-LinkForegroundColor <string >] [-ItalicsForegroundColor <string >] [<CommonParameters>]
60
66
61
67
Set-MarkdownOption -Theme <string> [<CommonParameters>]
62
68
@@ -65,6 +71,14 @@ Set-MarkdownOption -InputObject <psobject> [<CommonParameters>]
65
71
```
66
72
67
73
The properties can individually customize the rendering on console.
74
+ The properties for color must be expressed as a ` VT100 ` escape sequence, like
75
+
76
+ ``` PowerShell
77
+
78
+ Set-MarkdownOption -Header1Color "$([char]0x1b)[7m"
79
+
80
+ ```
81
+
68
82
Dark will be the default theme.
69
83
The individual colors for the dark theme are specified in the subsequent sections.
70
84
@@ -86,7 +100,7 @@ Export-MarkdownOption -LiteralPath <string> [<CommonParameters>]
86
100
87
101
```
88
102
89
- Export the current markdown settings to a file.
103
+ Export the current markdown settings to a JSON file.
90
104
91
105
### Specification for ` Import-MarkdownOption `
92
106
@@ -101,6 +115,22 @@ Import-MarkdownOption -LiteralPath <string> [<CommonParameters>]
101
115
Import the markdown settings from the specified file and returns a PSObject of the options.
102
116
This can be used as an ` InputObject ` for ` Set-MarkdownOption ` .
103
117
118
+ ### Specification for ` Show-Markdown `
119
+
120
+ ``` Powershell
121
+
122
+ Show-Markdown -InputObject <psobject[]> [<CommonParameters>]
123
+
124
+ Show-Markdown -InputObject <psobject[]> -UseBrowser [<CommonParameters>]
125
+
126
+ ```
127
+
128
+ Render the ` VT100EncodedString ` property of ` MarkdownInfo ` on console.
129
+ If the ` VT100EncodedString ` property is null, then a non-terminating error will be thrown.
130
+
131
+ If the switch ` -UseBrowser ` is specified, display the content of ` Html ` property in a web browser.
132
+ If the ` Html ` property is null, then a non-terminating error will be thrown.
133
+
104
134
## Supported Markdown Elements
105
135
106
136
We will be supporting a limited set of markdown elements in the initial version.
@@ -181,6 +211,16 @@ Escape code for images alt-text
181
211
| -------------| ----------| ----------|
182
212
| ![ ] ( ../assets/MarkdownRendering/Image-MD.png ) | ![ ] ( ../assets/MarkdownRendering/Image.png ) | ESC[ 33m[ alt-text] ESC[ 0m |
183
213
214
+ ### Rendered output
215
+
216
+ #### Input Markdown
217
+
218
+ ![ ] ( ../assets/MarkdownRendering/SampleMD.png )
219
+
220
+ #### VT100 Rendered output
221
+
222
+ ![ ] ( ../assets/MarkdownRendering/SampleVT100.png )
223
+
184
224
## Future Work
185
225
186
226
` Paragraphs and Line Breaks ` , ` Block Quotes ` , ` Lists ` , ` Horizontal Rules ` , ` Pipe tables ` and ` HTML code ` will be considered for future versions and rendered as plain text in this version.
0 commit comments