| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/gn/standard_out.h" | 5 #include "tools/gn/standard_out.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 OutputString(line.substr(begin_bracket, first_normal - begin_bracket), | 197 OutputString(line.substr(begin_bracket, first_normal - begin_bracket), |
| 198 DECORATION_DIM); | 198 DECORATION_DIM); |
| 199 } | 199 } |
| 200 | 200 |
| 201 OutputString(line.substr(first_normal) + "\n"); | 201 OutputString(line.substr(first_normal) + "\n"); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void PrintLongHelp(const std::string& text) { | 204 void PrintLongHelp(const std::string& text) { |
| 205 EnsureInitialized(); | 205 EnsureInitialized(); |
| 206 | 206 |
| 207 std::vector<std::string> lines; | |
| 208 base::SplitStringDontTrim(text, '\n', &lines); | |
| 209 | |
| 210 bool first_header = true; | 207 bool first_header = true; |
| 211 bool in_body = false; | 208 bool in_body = false; |
| 212 for (const auto& line : lines) { | 209 for (const std::string& line : base::SplitString( |
| 210 text, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL)) { |
| 213 // Check for a heading line. | 211 // Check for a heading line. |
| 214 if (!line.empty() && line[0] != ' ') { | 212 if (!line.empty() && line[0] != ' ') { |
| 215 if (is_markdown) { | 213 if (is_markdown) { |
| 216 // GN's block-level formatting is converted to markdown as follows: | 214 // GN's block-level formatting is converted to markdown as follows: |
| 217 // * The first heading is treated as an H2. | 215 // * The first heading is treated as an H2. |
| 218 // * Subsequent heading are treated as H3s. | 216 // * Subsequent heading are treated as H3s. |
| 219 // * Any other text is wrapped in a code block and displayed as-is. | 217 // * Any other text is wrapped in a code block and displayed as-is. |
| 220 // | 218 // |
| 221 // Span-level formatting (the decorations) is converted inside | 219 // Span-level formatting (the decorations) is converted inside |
| 222 // OutputString(). | 220 // OutputString(). |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 256 } |
| 259 } | 257 } |
| 260 | 258 |
| 261 OutputString(line + "\n", dec); | 259 OutputString(line + "\n", dec); |
| 262 } | 260 } |
| 263 | 261 |
| 264 if (is_markdown && in_body) | 262 if (is_markdown && in_body) |
| 265 OutputString("\n```\n"); | 263 OutputString("\n```\n"); |
| 266 } | 264 } |
| 267 | 265 |
| OLD | NEW |