-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix Markdown output to escape pipe character #1901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
adamsitnik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bakermo big thanks for your contribution! PTAL at my comments
| [PublicAPI] protected bool ColumnsStartWithSeparator; | ||
| [PublicAPI] protected string BoldMarkupFormat = "**{0}**"; | ||
| [PublicAPI] protected bool EscapeHtml; | ||
| [PublicAPI] protected bool EscapePipe; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that you are not setting the value of this property to true for StackOverflow, but for some reason the SO exporter is escaping it:
[MarkdownExporterAttribute.Default]
[MarkdownExporterAttribute.GitHub]
[MarkdownExporterAttribute.StackOverflow]
[MarkdownExporterAttribute.Atlassian]
public class Intro_MethodsParamsEscaped
{
[Params("Should|Escape", "ShouldNotEscape")] public string Param;
[Benchmark] public bool Method() => Param is null;
}dotnet run -c Release -f net5.0 --filter *Intro_MethodsParamsEscaped* --job dryCould you please ensure that it does not get escaped for the SO exporter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this should be fixed now.
Do we want to apply this escaping to console output? It would render as \| in the console, which is probably not desired, however there are comments in the code indicating that we want to support copy-paste from the console into Github:
| ColumnsStartWithSeparator = true // we want to be able to copy-paste the console output to GH #1062 |
| } | ||
|
|
||
| [RankColumn, LogicalGroupColumn, BaselineColumn] | ||
| public class MethodBaseline_MethodsParamsEscaped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
big thanks for adding a new approval test! 👍
|
BTW are there any other characters that should be escaped? |
|
@adamsitnik Appreciate the feedback!
From what I've seen from testing, the pipe character is the only one that breaks output, but I will make another pass to confirm this after addressing your other comments later today. |
|
@bakermo I think there should be Try run this ( public class Benchmarks
{
[Params("Shou\nld|Esca\ape")] public string Param;
[Benchmark] public bool Method() => Param is null;
} |
|
@YegorStepanov Ah, good catch. Yes, I agree. Do you think it would be best to have a single flag My inclination is to keep them separate, as |
|
@bakermo My opinion is exactly the same as yours. Separate them. I don't remember any other markdown-specific mistakes in the output, By implementing it you will close one or few other issues. You may find them and link to the PR. |
YegorStepanov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Have you corrected all Adam's comments?
It's not so easy to escape | in the console, because the table alignment will be broken. To fix it the big refactoring of the markdown exporter is required.
We will need to calculate the max column width and only after it, print the table.
In #2135 I've escaped the control characters (like '\0', '\a' - it's still making sound :))




Hello! Looking to get my feet wet contributing to open source. I've made changes here that should fix #1839.
This will escape the pipe

|character in markdown table cells by replacing it with\|so that the tables render properly.Example before escaping:
And after:
