platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

New-ExternalHelp not handling escaped characters correctly

Open daviesj opened this issue 5 years ago • 2 comments

New-ExternalHelp misinterprets pairs of escaped markdown characters in a paragraph. Looks like the parser that detects inline syntax such as bold or italic isn't checking for escaped characters.

Steps to reproduce

Create a markdown file with New-MarkdownHelp. Edit the description section as follows:

## DESCRIPTION
One \* asterisk seems to work ok.

There should be \* two \* asterisks in this line of output.

On this line, the word \**two** should be italic with an asterisk before and after.

Then run the markdown through New-ExternalHelp.

Note: The above markdown renders on GitHub as (omitting DESCRIPTION header):

One * asterisk seems to work ok.

There should be * two * asterisks in this line of output.

On this line, the word *two* should be italic with an asterisk before and after.

Expected behavior

Generated XML should be something like:

<maml:description>
  <maml:para>One * asterisk seems to work ok.</maml:para>
  <maml:para>There should be * two * asterisks in this line of output.</maml:para>
  <maml:para>On this line, the word * two * should be italic with an asterisk before and after.</maml:para>
</maml:description>

Actual behavior

Actual XML generated:

<maml:description>
  <maml:para>One * asterisk seems to work ok.</maml:para>
  <maml:para>There should be \ two \ asterisks in this line of output.</maml:para>
  <maml:para>On this line, the word \ two should be italic with an asterisk before and after.</maml:para>
</maml:description>

Environment data

platyPS 0.14.0 PowerShell 7.0 Windows 10 1903

daviesj avatar Mar 08 '20 02:03 daviesj

I think you need to escape the trailing asterisk as well. For example:

## DESCRIPTION
One \* asterisk seems to work ok.

There should be \* two \* asterisks in this line of output.

On this line, the word \**two*\* should be italic with an asterisk before and after.

Please test this with 0.14.2 and 2.0-preview1.

sdwheeler avatar Jul 27 '21 15:07 sdwheeler

I just ran into this today. To get the desired result with two asterisk on one line I used There should be *** two *** asterisks in this line of output.

It works but VSCode show problems from the Markdown linter. MD037/no-space-in-emphasis: Spaces inside emphasis markers

DarqueWarrior avatar Feb 12 '22 16:02 DarqueWarrior

The MAML conversion works totally differently in Microsoft.PowerShell.PlatyPS v1.

sdwheeler avatar May 24 '24 15:05 sdwheeler

This is fixed in Microsoft.PowerShell.PlatyPS v1.

sdwheeler avatar May 24 '24 18:05 sdwheeler