platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

Cannot support hyphen in language identifier of code block

Open dingmeng-xue opened this issue 3 years ago • 1 comments
trafficstars

Steps to reproduce

Given there is one existing PowerShell help markdown including below example. Please note its language identifier is azurepowershell-interactive

```azurepowershell-interactive
$rgName = "resourceGroupName"
$vnet = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name "vnet"
$pip = Get-AzPublicIpAddress -ResourceGroupName $rgName -Name "publicIpName"
New-AzFirewall -Name "azFw" -ResourceGroupName $rgName -Location centralus -VirtualNetwork $vnet -PublicIpAddress $pip
```

When developer update doc again via Update-MarkdownHelp, it becomes into

```azurepowershell
-interactive
$rgName = "resourceGroupName"
$vnet = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name "vnet"
$pip = Get-AzPublicIpAddress -ResourceGroupName $rgName -Name "publicIpName"
New-AzFirewall -Name "azFw" -ResourceGroupName $rgName -Location centralus -VirtualNetwork $vnet -PublicIpAddress $pip
```

You can see language identifier of code block doesn't support hyphen well. The text after hyphen is moved to the new line. We raise question because online doc will support more language identifiers https://review.docs.microsoft.com/en-us/help/contribute/code-in-docs?branch=master#inline-interactive-code-blocks

Expected behavior

```azurepowershell-interactive
$rgName = "resourceGroupName"
$vnet = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name "vnet"
$pip = Get-AzPublicIpAddress -ResourceGroupName $rgName -Name "publicIpName"
New-AzFirewall -Name "azFw" -ResourceGroupName $rgName -Location centralus -VirtualNetwork $vnet -PublicIpAddress $pip
```

Actual behavior

Environment data

Script 0.14.2 platyPS

PS C:\Dev> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.6
PSEdition                      Core
GitCommitId                    7.2.0-preview.6
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

dingmeng-xue avatar Jan 12 '22 00:01 dingmeng-xue

I think this may be fixed already in Microsoft.PowerShell.PlatyPS v1. Need to retest in Update scenario.

sdwheeler avatar May 24 '24 15:05 sdwheeler

This is resolved. The new PlatyPS just passes through the markdown content.

$c = import-MarkdownCommandHelp .\New-AzFirewall.md
$c.Examples[0] | fl *

Title   : Example 1: Create a Firewall attached to a virtual network
Remarks : ```azurepowershell-interactive
          $rgName = "resourceGroupName"
          $vnet = Get-AzVirtualNetwork -ResourceGroupName $rgName -Name "vnet"
          $pip = Get-AzPublicIpAddress -ResourceGroupName $rgName -Name "publicIpName"
          New-AzFirewall -Name "azFw" -ResourceGroupName $rgName -Location centralus -VirtualNetwork $vnet
          -PublicIpAddress $pip
          ```

          This example creates a Firewall attached to virtual network "vnet" in the same resource group as the
          firewall.
          Since no rules were specified, the firewall will block all traffic (default behavior).
          Threat Intel will also run in default mode - Alert - which means malicious traffic will be logged, but not
          denied.

sdwheeler avatar May 22 '25 17:05 sdwheeler