From 24dea483b8312efba669d82a6fac3603e60050f5 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sun, 18 Dec 2016 20:17:32 +0200 Subject: [PATCH] fix bold markup for Atlassian exporter --- .../Exporters/MarkdownExporter.cs | 6 ++++-- .../Reports/SummaryTableExtensions.cs | 12 ++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/BenchmarkDotNet.Core/Exporters/MarkdownExporter.cs b/src/BenchmarkDotNet.Core/Exporters/MarkdownExporter.cs index 293bd2b1ae..6d234459fb 100644 --- a/src/BenchmarkDotNet.Core/Exporters/MarkdownExporter.cs +++ b/src/BenchmarkDotNet.Core/Exporters/MarkdownExporter.cs @@ -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; @@ -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() { @@ -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++; } } diff --git a/src/BenchmarkDotNet.Core/Reports/SummaryTableExtensions.cs b/src/BenchmarkDotNet.Core/Reports/SummaryTableExtensions.cs index 91299969c0..eb723c1724 100644 --- a/src/BenchmarkDotNet.Core/Reports/SummaryTableExtensions.cs +++ b/src/BenchmarkDotNet.Core/Reports/SummaryTableExtensions.cs @@ -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++) { @@ -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 @@ -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();