From 28328f1366db8bce39bd5a862f835d778b91d5ca Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 12 Apr 2018 17:42:06 +0200 Subject: Add support for note block and span For example: \N|This is a block note. It may consist of multiple paragraphs.| And this is \N{an inline note} that is inside a paragraph. Notes are currently only support for the html output. --- cli/context.cxx | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 5 deletions(-) (limited to 'cli') diff --git a/cli/context.cxx b/cli/context.cxx index b7181fd..a0900ce 100644 --- a/cli/context.cxx +++ b/cli/context.cxx @@ -419,6 +419,7 @@ format_line (output_type ot, string& r, const char* s, size_t n) const block itlc = 2; const block bold = 4; const block link = 8; + const block note = 16; vector blocks; @@ -753,6 +754,19 @@ format_line (output_type ot, string& r, const char* s, size_t n) r += 'l'; break; } + case 'N': + { + if (i + 1 < n && s[i + 1] == '{') + { + ++i; + blocks.push_back (note); + new_block = true; + break; + } + + r += 'N'; + break; + } case '\\': { switch (ot) @@ -815,6 +829,13 @@ format_line (output_type ot, string& r, const char* s, size_t n) { case ot_plain: { + if ((b & note) != 0) + { + cerr << "error: \\N{} in plain text output not yet supported" + << endl; + throw generation_failed (); + } + if ((b & link) == 0) { if (color) @@ -831,7 +852,11 @@ format_line (output_type ot, string& r, const char* s, size_t n) } case ot_html: { - if (b & link) + if (b & note) + { + r += ""; + } + else if (b & link) { r += "= 3 && + l[0] == '\\' && + l[1] == 'N' && + (l[2] == '|' || l[2] == '#')) + { + k = block::note; + l += 3; + n -= 3; + } else k = block::text; @@ -1474,7 +1527,10 @@ format (semantics::scope& scope, string const& s, bool para) case block::ul: case block::ol: case block::dl: good = (k == block::li); break; - case block::li: good = (k == block::text || k == block::pre); break; + case block::li: good = (k == block::note || + k == block::text || + k == block::pre ); break; + case block::note: good = (k == block::text || k == block::pre); break; case block::text: good = (k != block::li); break; case block::pre: assert (false); } @@ -1569,6 +1625,7 @@ format (semantics::scope& scope, string const& s, bool para) break; } + case block::note: case block::text: case block::pre: break; @@ -1606,6 +1663,11 @@ format (semantics::scope& scope, string const& s, bool para) blocks.push (block (k, false, id, header)); break; } + case block::note: + { + blocks.push (block (k, true, id, header)); + break; + } case block::text: break; // No push. case block::pre: break; // No push. } @@ -2025,6 +2087,12 @@ format (semantics::scope& scope, string const& s, bool para) break; } + case block::note: + { + cerr << "error: " << pb.kind << "| in plain text output not " + << "yet supported" << endl; + throw generation_failed (); + } case block::text: case block::pre: assert (false); } @@ -2112,6 +2180,14 @@ format (semantics::scope& scope, string const& s, bool para) break; } + case block::note: + { + v += "
\n"; + v += pv; + v += "\n
"; + + break; + } case block::text: case block::pre: assert (false); } @@ -2165,6 +2241,12 @@ format (semantics::scope& scope, string const& s, bool para) break; } + case block::note: + { + cerr << "error: " << pb.kind << "| in man output not yet " + << "supported" << endl; + throw generation_failed (); + } case block::text: case block::pre: assert (false); } -- cgit v1.1