#include "support/FileNameList.h"
#include "support/gettext.h"
#include "support/lstrings.h"
-#include "support/textutils.h"
#include <algorithm>
#include <climits>
os << "}";
}
+
pair<int, int> InsetCitation::isWords() const
{
docstring const label = generateLabel(false);
- int words = 1;
- for (auto const & c : label) {
- if (lyx::isSpace(c))
- words++;
- }
- return pair<int, int>(label.size(), words);
+ return pair<int, int>(label.size(), wordCount(label));
}
}
+pair<int, int> InsetHyperlink::isWords() const
+{
+ docstring const label = getParam("name");
+ return pair<int, int>(label.size(), wordCount(label));
+}
+
+
string InsetHyperlink::contextMenuName() const
{
return "context-hyperlink";
void docbook(XMLStream &, OutputParams const &) const override;
///
docstring xhtml(XMLStream &, OutputParams const &) const override;
+ ///
+ std::pair<int, int> isWords() const override;
//@}
/// \name Static public methods obligated for InsetCommand derived classes
}
+int wordCount(docstring const & d)
+{
+ docstring dt = trim(d);
+ if (dt.empty())
+ return 0;
+ int words = 1;
+ for (auto const & c : dt) {
+ if (isSpace(c))
+ words++;
+ }
+ return words;
+}
+
+
+
int count_bin_chars(string const & str)
{
QString const qstr = toqstr(str).simplified();
/// Count all occurrences of char \a chr inside \a str
int count_char(docstring const & str, docstring::value_type chr);
+/// get an approximate word count
+int wordCount(docstring const &);
+
/** Count all occurrences of binary chars inside \a str.
It is assumed that \a str is utf-8 encoded and that a binary char
belongs to the unicode class names Zl, Zp, Cc, Cf, Cs, Co, or Cn