commit c59375d67915077a2dbf7e8bb29768dc379fb797
Author: Juergen Spitzmueller <[email protected]>
Date: Sun Jan 29 12:08:29 2017 +0100
Move protectArgument function to lstrings
This will be useful to other insets as well.
---
src/insets/InsetCitation.cpp | 9 ---------
src/support/lstrings.cpp | 10 ++++++++++
src/support/lstrings.h | 4 ++++
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp
index 40b8c1d..6f238f9 100644
--- a/src/insets/InsetCitation.cpp
+++ b/src/insets/InsetCitation.cpp
@@ -312,15 +312,6 @@ inline docstring wrapCitation(docstring const & key,
html::htmlize(content, XHTMLStream::ESCAPE_ALL) +
"</a>";
}
-docstring protectArgument(docstring & arg, char const l = '[',
- char const r = ']')
-{
- if (contains(arg, l) || contains(arg, r))
- // protect brackets
- arg = '{' + arg + '}';
- return arg;
-}
-
} // anonymous namespace
diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp
index 1e3d346..8ffab19 100644
--- a/src/support/lstrings.cpp
+++ b/src/support/lstrings.cpp
@@ -1203,6 +1203,16 @@ docstring const escape(docstring const & lab)
}
+docstring const protectArgument(docstring & arg, char const l,
+ char const r)
+{
+ if (contains(arg, l) || contains(arg, r))
+ // protect brackets
+ arg = '{' + arg + '}';
+ return arg;
+}
+
+
bool truncateWithEllipsis(docstring & str, size_t const len)
{
if (str.size() <= len)
diff --git a/src/support/lstrings.h b/src/support/lstrings.h
index 9719513..36ba09f 100644
--- a/src/support/lstrings.h
+++ b/src/support/lstrings.h
@@ -269,6 +269,10 @@ docstring const rsplit(docstring const & a, char_type
delim);
/// problems in latex labels.
docstring const escape(docstring const & lab);
+/// Group contents of an argument if needed
+docstring const protectArgument(docstring & arg, char const l = '[',
+ char const r = ']');
+
/// Truncates a string with an ellipsis at the end. Leaves str unchanged and
/// returns false if it is shorter than len. Otherwise resizes str to len, with
/// U+2026 HORIZONTAL ELLIPSIS at the end, and returns true.