platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

Loss of carriage return issues for MD to MAML and then back to MD

Open chrisda opened this issue 6 years ago • 1 comments

Steps to reproduce

I ran the following command to get our individual markdown topics into MAML files for check-in back into code:

New-ExternalHelp -Path <Path> -ApplicableTag "<TagValue>" -OutputPath <Path> -ErrorLogFile <FileAndPath>

I then ran the following command to use one of the MAML files as the source to dump the cmdlets back into individual markdown topics:

New-MarkdownHelp -MamlFile "<MAMLFileAndPath>" -OutputFolder "<Path>"

Expected behavior

The formatting of the resulting markdown topics should be basically the same as the source markdown topics.

Actual behavior

Carriage returns are eliminated in bulleted lists and other multi-paragraph situations (parameter descriptions, example descriptions, etc.).

For example, in Add-AttachmentFilterEntry.md

The description of the Type parameter looks like this in the source topic:

### -Type
The Type parameter specifies what type of attachment the attachment filter entry blocks. Valid values are ContentType and FileName:

- ContentType: This value matches the attachment filter entry against the MIME content type specified in the Name parameter.

- FileName: This value matches the attachment filter entry against the simple file name specified in the Name parameter.

But the same parameter description looks like this in the output topic:

### -Type
The Type parameter specifies what type of attachment the attachment filter entry blocks.
Valid values are ContentType and FileName:

- ContentType: This value matches the attachment filter entry against the MIME content type specified in the Name parameter.
- FileName: This value matches the attachment filter entry against the simple file name specified in the Name parameter.

I realize a new line without a blank line in between is the same as one long line. But why is the blank line between the bullets lost?

See the attached files for details.

Is this related to #210 and #212? I don't think so, but I'll take that under advisement.

Environment data

platyPS v0.12.0

Original markdown topics

MAML file from original markdown topics

Markdown topics from MAML file

chrisda avatar Jan 18 '19 02:01 chrisda

Hi Chris,

PlatyPS MamlModel (which is the data model for the intermediate representation) is not carrying the formatted data at the moment. While being translated from markdown it normalizes to a simple text that is equivalent to markdown output. For example, the extra blank line between the bullet point list doesn't affect the way it's rendered, but it does matter for the text paragraphs.

It's possible in theory to capture the original markdown formatting in MamlModel and re-use it, but it's a significant amount of work to implement. I outlined solutions in a similar problem at https://github.com/PowerShell/platyPS/issues/422#issuecomment-453806051

Without fundamental changes to the data model, it would not be possible to support full formatting preservation.

vors avatar Jan 18 '19 05:01 vors

The scenario is going to be different with Microsoft.PowerShell.PlatyPS v1. Rendering to MAML produces lower fidelity content, but the quality is improved in the v1 code.

sdwheeler avatar May 24 '24 15:05 sdwheeler

Retested Microsoft.PowerShell.PlatyPS v1. Current conversion to MAML removes empty lines in examples.

sdwheeler avatar May 24 '24 18:05 sdwheeler

Tracking newline issues in #508

sdwheeler avatar May 24 '24 18:05 sdwheeler