lijunle / Vsxmd

VS XML documentation -> Markdown syntax.
MIT License
217 stars 52 forks source link

Newlines are not handled appropriately #96

Open astrohart opened 2 years ago

astrohart commented 2 years ago

I have a project I am building, DummyFormsApp. It has Vsxmd 1.4.5 installed.

I have XML comment text in the DummyFormsApp.xml file such as:

<member name="M:DummyFormsApp.MainWindow.OnFileExit(System.Object,System.EventArgs)">
    <summary>
    Handles the <see cref="E:System.Windows.Forms.ToolStripItem.Click" /> event
    raised by the <b>Exit</b> item on the <b>File</b> menu.
    </summary>
    <param name="sender">
    Reference to an instance of the object that raised the
    event.
    </param>
    <param name="e">
    A <see cref="T:System.EventArgs" /> that contains the event
    data.
    </param>
    <remarks>
    This method responds by calling the
    <see cref="M:System.Windows.Forms.Form.Close" /> method to close this window,
    which by extension also exits the application.
    </remarks>
</member>

It is this way because I also utilize JetBrains ReSharper and I have it programmed to make all lines XX chars long and no longer (code style). So it hard wraps longer lines, including XML doc comments. I prefer it this way.

However, it produces DummyFormsApp.md content as shown:

image

This has line breaks etc. in it. You need to replace all Environment.NewLine occurrences in the incoming XML documentation file with (blank spaces) during processing.

The current code is preserving line breaks and this is making the .md not be formatted correctly.

lijunle commented 2 years ago

Hi, @astrohart How does your document file (the .xml file) look like?

astrohart commented 1 year ago

Let me upload a sample, here you go: MFR.Engines.xml.txt

(I had to rename it with a .xml.txt extension otherwise GitHub won't allow the file to be uploaded)

One of the entries looks like this

        <member name="P:MFR.Engines.ConsoleOperationEngine.Type">
            <summary>
            Gets a <see cref="T:MFR.Engines.Constants.OperationEngineType" /> enumeration
            value that describes what type of operation engine this is.
            </summary>
            <remarks>
            Child classes must implement this property.
            </remarks>
        </member>

Notice the line break after enumeration this is by design for my side, because my code formatter style rules are set accordingly and I can't change them. When I "show all symbols" on the file in Notepad++, it is evident that there is a \r\n after the word enumeration.

I recommend you do something such as value.Replace("\r\n", " ") after you have read the body of a XML tag (assuming value is the variable that your code read it into), and replace it with a single whitespace character, not an empty string.

astrohart commented 1 year ago

MFR.Engines.md

For reference, I am attaching the corresponding .md file generated by Vsxmd that matches the XML file I submitted above for your comparison.