Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: tools/gn/standard_out.cc

Issue 1301423006: Escape "--" in markdown rendering for GN reference docs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn_reference
Patch Set: fix second dec== Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/docs/reference.md ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/standard_out.cc
diff --git a/tools/gn/standard_out.cc b/tools/gn/standard_out.cc
index 6d3960e6f4863b418cc333c92fbeb527c9a5511d..0c5b54f5fd288b30f9e0c065db368df2899f32e4 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,7 +126,15 @@ void OutputString(const std::string& output, TextDecoration dec) {
}
}
- ::WriteFile(hstdout, output.c_str(), static_cast<DWORD>(output.size()),
+ std::string tmpstr = output;
+ if (is_markdown && dec == DECORATION_YELLOW) {
+ // 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, "--", "\\--");
+ }
+ ::WriteFile(hstdout, tmpstr.c_str(), static_cast<DWORD>(tmpstr.size()),
&written, nullptr);
if (is_markdown) {
@@ -162,7 +172,15 @@ void OutputString(const std::string& output, TextDecoration dec) {
}
}
- WriteToStdOut(output.data());
+ std::string tmpstr = output;
+ if (is_markdown && dec == DECORATION_YELLOW) {
+ // 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, "--", "\\--");
+ }
+ WriteToStdOut(tmpstr.data());
if (is_markdown) {
OutputMarkdownDec(dec);
« no previous file with comments | « tools/gn/docs/reference.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698