Skip to content

Commit 15e33f1

Browse files
Address comments from committee
1 parent 60bc1ca commit 15e33f1

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

2-Draft-Accepted/RFCNNNN-Native-Markdown-Rendering.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Render markdown content on console to improve readability.
1717

1818
Markdown is a common authoring format used by the community.
1919
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.
2021

2122
## Specification
2223

@@ -25,8 +26,9 @@ This RFC proposes to use `VT100` escape sequences to render markdown content.
2526
The `Tokens` property has the AST for the markdown document from `markdig`.
2627
The `Html` property has the markdown document converted to `HTML`.
2728
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.
2930
The `VT100EncodedString` property will be populated only when `-AsVT100EncodedString` is specified.
31+
The `Tokens` property will be populated in all cases.
3032

3133
For converting strings to VT100 coded strings, we will be writing an extension to [markdig](https://github.com/lunet-io/markdig).
3234
The extension will insert VT100 escape sequences as appropriate.
@@ -52,11 +54,15 @@ ConvertFrom-Markdown [-InputObject] <psobject> [-AsVT100EncodedString] [<CommonP
5254

5355
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.
5456

57+
#### Output Type
58+
59+
The output type will be `MarkdownInfo` object with properties for `Html`, `VT100EncodedString` and `Tokens`.
60+
5561
### Specification for `Set-MarkdownOption`
5662

5763
```PowerShell
5864
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>]
6066
6167
Set-MarkdownOption -Theme <string> [<CommonParameters>]
6268
@@ -65,6 +71,14 @@ Set-MarkdownOption -InputObject <psobject> [<CommonParameters>]
6571
```
6672

6773
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+
6882
Dark will be the default theme.
6983
The individual colors for the dark theme are specified in the subsequent sections.
7084

@@ -86,7 +100,7 @@ Export-MarkdownOption -LiteralPath <string> [<CommonParameters>]
86100
87101
```
88102

89-
Export the current markdown settings to a file.
103+
Export the current markdown settings to a JSON file.
90104

91105
### Specification for `Import-MarkdownOption`
92106

@@ -101,6 +115,22 @@ Import-MarkdownOption -LiteralPath <string> [<CommonParameters>]
101115
Import the markdown settings from the specified file and returns a PSObject of the options.
102116
This can be used as an `InputObject` for `Set-MarkdownOption`.
103117

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+
104134
## Supported Markdown Elements
105135

106136
We will be supporting a limited set of markdown elements in the initial version.
@@ -181,6 +211,16 @@ Escape code for images alt-text
181211
|-------------|----------|----------|
182212
| ![](../assets/MarkdownRendering/Image-MD.png) | ![](../assets/MarkdownRendering/Image.png) | ESC[33m[alt-text]ESC[0m |
183213

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+
184224
## Future Work
185225

186226
`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.

assets/MarkdownRendering/SampleMD.PNG

55.6 KB
Loading
51.8 KB
Loading

0 commit comments

Comments
 (0)