-
-
Notifications
You must be signed in to change notification settings - Fork 10
Description
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?