summaryrefslogtreecommitdiff
path: root/cli/source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-11-12 12:37:24 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-11-12 12:37:24 +0200
commit124341e83bb9e8959508fac8c798506f82f21938 (patch)
tree18d85148557c52ecaf5a71d62d94d57b1879d215 /cli/source.cxx
parent83996ed8d7178750a0b96125b209cc97ce5ddba0 (diff)
Implement plain text formatting for new blocks
Diffstat (limited to 'cli/source.cxx')
-rw-r--r--cli/source.cxx17
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;
}