1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
From 8c7c3ef5a20529366322297bbdb4b53868cb62e4 Mon Sep 17 00:00:00 2001
From: smehringer <svenja.mehringer@fu-berlin.de>
Date: Mon, 12 Feb 2018 16:22:54 +0000
Subject: [PATCH] [INTERNAL] Fixes man page output: Escape special characters
'.' or ''' at the beginning of a line.
---
include/seqan/arg_parse/tool_doc.h | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/include/seqan/arg_parse/tool_doc.h b/include/seqan/arg_parse/tool_doc.h
index 78f7db717..c31460287 100644
--- a/include/seqan/arg_parse/tool_doc.h
+++ b/include/seqan/arg_parse/tool_doc.h
@@ -1531,6 +1531,20 @@ void TextToolDocPrinter_::print(std::ostream & stream, ToolDoc const & doc)
}
}
+// --------------------------------------------------------------------------
+// Function ManToolDocPrinter_::print()
+// --------------------------------------------------------------------------
+
+//brief: "." or "'" indicate man page macros that need to be escaped with "\\&"
+template <typename TString>
+void print_first_in_line(std::ostream & stream, TString const & str)
+{
+ if (length(str) > 0 &&
+ (str[0] == '.' || str[0] == '\''))
+ stream << "\\&";
+ stream << str;
+}
+
inline
void ManToolDocPrinter_::print(std::ostream & stream, ToolDoc const & doc)
{
@@ -1580,7 +1594,8 @@ void ManToolDocPrinter_::print(std::ostream & stream, ToolDoc const & doc)
stream << ".sp\n";
else if (!isFirstInSection && !line->isParagraph())
stream << ".br\n";
- stream << line->_text << "\n";
+ print_first_in_line(stream, line->_text);
+ stream << "\n";
isFirstInSection = false;
}
break;
@@ -1588,9 +1603,11 @@ void ManToolDocPrinter_::print(std::ostream & stream, ToolDoc const & doc)
case ToolDocEntry_::LIST_ITEM:
{
ToolDocListItem_ const * item = static_cast<ToolDocListItem_ const *>(entry);
- stream << ".TP\n"
- << item->_term << "\n"
- << item->_description << "\n";
+ stream << ".TP\n";
+ print_first_in_line(stream, item->_term);
+ stream << "\n";
+ print_first_in_line(stream, item->_description);
+ stream << "\n";
isFirstInSection = false;
}
break;
|