summaryrefslogtreecommitdiff
path: root/cli/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-11-26 08:17:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-11-26 08:17:28 +0200
commita9fd81899df8a412f20784b3575b9707c530d1d1 (patch)
tree6fca6398cd3f719262695049bc720b97eabb1f67 /cli/context.cxx
parent4d9706d81ef5415556289c97f3fbaa899816070c (diff)
Indent multi-line lists in plain text output
Diffstat (limited to 'cli/context.cxx')
-rw-r--r--cli/context.cxx21
1 files changed, 18 insertions, 3 deletions
diff --git a/cli/context.cxx b/cli/context.cxx
index 5731222..25a88a0 100644
--- a/cli/context.cxx
+++ b/cli/context.cxx
@@ -1375,14 +1375,29 @@ format (output_type ot, string const& s, bool para)
case block::li:
{
v += sn;
+ size_t ind (0);
switch (b.kind)
{
- case block::ul: v += "* " + pv; break;
- case block::ol: v += ph + ". " + pv; break;
- case block::dl: v += ph + "\n " + pv; break;
+ case block::ul: v += "* "; ind = 2; break;
+ case block::ol: v += ph + ". "; ind = ph.size () + 2; break;
+ case block::dl: v += ph + "\n "; ind = 8; break;
default: break;
}
+
+ // Add value with indentation for subsequent paragraphs.
+ //
+ char c, p ('\0'); // Current and previous characters.
+ for (size_t i (0); i != pv.size (); p = c, ++i)
+ {
+ c = pv[i];
+
+ if (p == '\n' && c != '\n') // Don't indent blanks.
+ v += string (ind, ' ');
+
+ v += c;
+ }
+
break;
}
case block::text: