diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-12 12:37:24 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-11-12 12:37:24 +0200 |
commit | 124341e83bb9e8959508fac8c798506f82f21938 (patch) | |
tree | 18d85148557c52ecaf5a71d62d94d57b1879d215 /cli/source.cxx | |
parent | 83996ed8d7178750a0b96125b209cc97ce5ddba0 (diff) | |
download | cli-124341e83bb9e8959508fac8c798506f82f21938.tar.gz cli-124341e83bb9e8959508fac8c798506f82f21938.tar.xz cli-124341e83bb9e8959508fac8c798506f82f21938.zip |
Implement plain text formatting for new blocks
Diffstat (limited to 'cli/source.cxx')
-rw-r--r-- | cli/source.cxx | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/cli/source.cxx b/cli/source.cxx index 19cdb82..971c639 100644 --- a/cli/source.cxx +++ b/cli/source.cxx @@ -319,13 +319,13 @@ namespace if (d[i] == ' ' || d[i] == '\n') e = i; - // Assume we have 78 characters instead of 79 per line to make - // sure we get the same output on Windows (which has two character - // for a newline). + // Assume we have 78 characters instead of 79 per line to make sure + // we get the same output on Windows (which has two characters for + // a newline). // if (d[i] == '\n' || i - b == 78 - length_) { - if (b != 0) + if (b != 0) // Not a first line. { os << endl << " << \""; @@ -335,9 +335,14 @@ namespace string s (d, b, (e != b ? e : i) - b); os << escape_str (s) << "\" << ::std::endl"; + // Handle consecutive newlines (e.g., pre, paragraph separator). + // if (d[i] == '\n') - os << endl - << " << ::std::endl"; + { + for (; i + 1 < n && d[i + 1] == '\n'; e = ++i) + os << endl + << " << ::std::endl"; + } b = e = (e != b ? e : i) + 1; } |