From a9fd81899df8a412f20784b3575b9707c530d1d1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 26 Nov 2015 08:17:28 +0200 Subject: Indent multi-line lists in plain text output --- cli/context.cxx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'cli/context.cxx') 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: -- cgit v1.1