Out-Display
cmdlet¶If you want to write out a string
as HTML, you can use the Out-Display
cmdlet:
'<b style="color:blue">Hello!</b>' | Out-Display
Out-Display
also allows you to specify the MIME type which gives you the ability to:
# Output JavaScript
Out-Display "alert('Hello!');" -MimeType application/javascript
# Output Markdown
Out-Display "**BOLD** _ITALICS_" -MimeType text/markdown
If you want to use your own MIME type on one not defined in -MimeType
you can use the -CustomMimeType
parameter:
Invoke-WebRequest https://raw.githubusercontent.com/PowerShell/PowerShell/master/assets/avatar_128.svg |
Select-Object -ExpandProperty Content |
Out-Display -CustomMimeType 'image/svg+xml'
There are also several magic commands that can be used to output HTML in your .NET notebook.
You can output HTML...
#!html
<b>Hello!</b>
...or run JavaScript...
#!javascript
alert("hello");
...or render Markdown.
#!markdown
Write a **list** ...
* first
* second
...or a _table_...
|Fruit |Texture |
|---------|--------|
|apple |smooth |
|durian |bumpy |