Chromium Code Reviews| Index: tools/gn/standard_out.cc |
| diff --git a/tools/gn/standard_out.cc b/tools/gn/standard_out.cc |
| index 6d3960e6f4863b418cc333c92fbeb527c9a5511d..696050e3933e017e2b4316953d59d0c177e6344c 100644 |
| --- a/tools/gn/standard_out.cc |
| +++ b/tools/gn/standard_out.cc |
| @@ -8,7 +8,9 @@ |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| +#include "base/strings/string_piece.h" |
| #include "base/strings/string_split.h" |
| +#include "base/strings/string_util.h" |
| #include "build/build_config.h" |
| #include "tools/gn/switches.h" |
| @@ -124,8 +126,22 @@ void OutputString(const std::string& output, TextDecoration dec) { |
| } |
| } |
| - ::WriteFile(hstdout, output.c_str(), static_cast<DWORD>(output.size()), |
| - &written, nullptr); |
| + // https://code.google.com/p/gitiles/issues/detail?id=77 |
| + // Gitiles will replace "--" with an em dash in non-code text. |
| + // Figuring out all instances of this might be difficult, but |
| + // we can at least escape the instances where this shows up in |
| + // a heading. |
| + if (is_markdown && dec==DECORATION_YELLOW) { |
|
brettw
2015/09/04 18:04:29
Need spaces around ==
|
| + std::string tmpstr = output; |
|
brettw
2015/09/04 18:04:30
Why not just do
if (...) {
base::ReplaceSubs
Dirk Pranke
2015/09/05 01:53:42
output is a const, so we can't modify it.
I've u
|
| + base::ReplaceSubstringsAfterOffset(&tmpstr, 0, |
| + StringPiece("--"), |
| + StringPiece("\\--")); |
|
Dirk Pranke
2015/09/03 01:04:45
Is this the best/easiest way to do a "replace all"
brettw
2015/09/04 18:04:29
Sure, but you can remove the explicit StringPiece
|
| + ::WriteFile(hstdout, tmpstr.c_str(), static_cast<DWORD>(tmpstr.size()), |
| + &written, nullptr); |
| + } else { |
| + ::WriteFile(hstdout, output.c_str(), static_cast<DWORD>(output.size()), |
| + &written, nullptr); |
| + } |
| if (is_markdown) { |
| OutputMarkdownDec(dec); |
| @@ -162,7 +178,21 @@ void OutputString(const std::string& output, TextDecoration dec) { |
| } |
| } |
| - WriteToStdOut(output.data()); |
| + if (is_markdown && dec==DECORATION_YELLOW) { |
|
brettw
2015/09/04 18:04:29
Ditto
|
| + std::string tmpstr = output; |
|
brettw
2015/09/04 18:04:29
Ditto
|
| + |
| + // https://code.google.com/p/gitiles/issues/detail?id=77 |
| + // Gitiles will replace "--" with an em dash in non-code text. |
| + // Figuring out all instances of this might be difficult, but |
| + // we can at least escape the instances where this shows up in |
| + // a heading. |
| + base::ReplaceSubstringsAfterOffset(&tmpstr, 0, |
| + base::StringPiece("--"), |
| + base::StringPiece("\\--")); |
| + WriteToStdOut(tmpstr.data()); |
| + } else { |
| + WriteToStdOut(output.data()); |
| + } |
| if (is_markdown) { |
| OutputMarkdownDec(dec); |