Skip to content

Commit

Permalink
Merge pull request #329 from lahma/features/atlassian-bold-format
Browse files Browse the repository at this point in the history
fix bold markup for Atlassian exporter
  • Loading branch information
adamsitnik committed Dec 30, 2016
2 parents 2e92a28 + 24dea48 commit aabece9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/BenchmarkDotNet.Core/Exporters/MarkdownExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public class MarkdownExporter : ExporterBase
columnsStartWithSeparator = true,
useCodeBlocks = true,
codeBlockStart = "{noformat}",
codeBlockEnd = "{noformat}"
codeBlockEnd = "{noformat}",
boldMarkupFormat = "*{0}*"
};

private string prefix = string.Empty;
Expand All @@ -60,6 +61,7 @@ public class MarkdownExporter : ExporterBase
private string tableColumnSeparator = " |";
private bool useHeaderSeparatingRow = true;
private bool columnsStartWithSeparator = false;
private string boldMarkupFormat = "**{0}**";

private MarkdownExporter()
{
Expand Down Expand Up @@ -148,7 +150,7 @@ private void PrintTable(SummaryTable table, ILogger logger)
logger.Write(tableColumnSeparator);
}

table.PrintLine(line, logger, string.Empty, tableColumnSeparator, highlightRow, table.FullContentStartOfGroup[rowCounter], startOfGroupInBold);
table.PrintLine(line, logger, string.Empty, tableColumnSeparator, highlightRow, table.FullContentStartOfGroup[rowCounter], startOfGroupInBold, boldMarkupFormat);
rowCounter++;
}
}
Expand Down
12 changes: 4 additions & 8 deletions src/BenchmarkDotNet.Core/Reports/SummaryTableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void PrintLine(this SummaryTable table, string[] line, ILogger log
}

public static void PrintLine(this SummaryTable table, string[] line, ILogger logger, string leftDel, string rightDel,
bool highlightRow, bool startOfGroup, bool startOfGroupInBold)
bool highlightRow, bool startOfGroup, bool startOfGroupInBold, string boldMarkupFormat)
{
for (int columnIndex = 0; columnIndex < table.ColumnCount; columnIndex++)
{
Expand All @@ -56,7 +56,7 @@ public static void PrintLine(this SummaryTable table, string[] line, ILogger log
}

var text = (startOfGroup && startOfGroupInBold)
? BuildBoldText(table, line, leftDel, rightDel, columnIndex)
? BuildBoldText(table, line, leftDel, rightDel, columnIndex, boldMarkupFormat)
: BuildStandardText(table, line, leftDel, rightDel, columnIndex);

if (highlightRow) // write the row in an alternative colour
Expand Down Expand Up @@ -84,17 +84,13 @@ private static string BuildStandardText(SummaryTable table, string[] line, strin
return buffer.ToString();
}

private static string BuildBoldText(SummaryTable table, string[] line, string leftDel, string rightDel, int columnIndex)
private static string BuildBoldText(SummaryTable table, string[] line, string leftDel, string rightDel, int columnIndex, string boldMarkupFormat)
{
const string markdownBold = "**";

var buffer = GetClearBuffer();

buffer.Append(leftDel);
PadLeft(table, line, leftDel, rightDel, columnIndex, buffer);
buffer.Append(markdownBold);
buffer.Append(line[columnIndex]);
buffer.Append(markdownBold);
buffer.AppendFormat(boldMarkupFormat, line[columnIndex]);
buffer.Append(rightDel);

return buffer.ToString();
Expand Down

0 comments on commit aabece9

Please sign in to comment.