Skip to content

Unable to control escaping of common characters such as '.' and '-' which destroys plain-text readability #47

@NameOfTheDragon

Description

@NameOfTheDragon

I'm using MarkdownWriter to render markdown into a StringBuilder. Example code:

        md.WriteStartTable(columns);
        md.WriteStartTableRow();
        foreach (var heading in columnHeadings)
        {
            md.WriteStartTableCell();
            md.WriteString(heading);
            md.WriteEndTableCell();
        }

        md.WriteEndTableRow();
        md.WriteTableHeaderSeparator();

The default escaper escapes common characters such as '.' and '-'. This destroys readability when viewing with a simple text editor such as Notepad. For example, consider this table of measurements:

Measurement    | Value   | Units        | Acceptance Criteria | Disposition
---------------|---------|--------------|---------------------|------------
Burst Duration | 458\.55 | milliseconds | Minimum 400\.00     | Pass
Power          | 2\.7651 | Volts        | Minimum 2\.0000     | Pass
Feedback Volts | 3\.2998 | Volts        | Minimum 2\.2240     | Pass
Battery level  | 6\.0077 | Volts        | Minimum 5\.0000     | Pass
Temperature    | 26\.60  | °C           |                     | Information

vs. the unescaped version:

Measurement    | Value  | Units        | Acceptance Criteria | Disposition
---------------|--------|--------------|---------------------|------------
Burst Duration | 458.55 | milliseconds | Minimum 400.00      | Pass
Power          | 2.7651 | Volts        | Minimum 2.0000      | Pass
Feedback Volts | 3.2998 | Volts        | Minimum 2.2240      | Pass
Battery level  | 6.0077 | Volts        | Minimum 5.0000      | Pass
Temperature    | 26.60  | °C           |                     | Information

Having Markdown files readable as plain text with no special software was one of the attractions of using the format, so I need to not escape any characters at all (I'm careful about what I write so this will not be an issue in my use-case). I can see there is an escaper variant called NoEscape, which seems to be exactly what I need, however I cannot find any way to inject it into the settings. The only place I can see this being set is as a default value in MarkdownBaseWriter, and my IDE says the set accessor is never used:

    protected MarkdownCharEscaper Escaper { get; set; } = MarkdownCharEscaper.Default;

Therefore, even though there are several escapers available, there seems to be no way to use anything but MarkdownCharEscaper.Default, which is DefaultMarkdownEscaper, which is too aggressive.

Would it be possible to be able to set the escaper, please? Possible via MarkdownWriterSettings?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions