Result list snippets: incorrect page number detection could sometimes prevent highlighting
This commit is contained in:
parent
2f6a34d2b4
commit
cdaa86b9a0
@ -148,6 +148,8 @@ void ResListPager::resultPageFor(int docnum)
|
|||||||
m_respage = npage;
|
m_respage = npage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const SimpleRegexp pagenumre("(^ *\\[[pP]\\.* [0-9]+\\])", 0);
|
||||||
|
|
||||||
void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
|
void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
|
||||||
const HighlightData& hdata, const string& sh)
|
const HighlightData& hdata, const string& sh)
|
||||||
{
|
{
|
||||||
@ -220,23 +222,26 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
|
|||||||
string richabst;
|
string richabst;
|
||||||
bool needabstract = parFormat().find("%A") != string::npos;
|
bool needabstract = parFormat().find("%A") != string::npos;
|
||||||
if (needabstract && m_docSource) {
|
if (needabstract && m_docSource) {
|
||||||
vector<string> vabs;
|
vector<string> snippets;
|
||||||
m_docSource->getAbstract(doc, vabs);
|
m_docSource->getAbstract(doc, snippets);
|
||||||
m_hiliter->set_inputhtml(false);
|
m_hiliter->set_inputhtml(false);
|
||||||
|
|
||||||
for (vector<string>::const_iterator it = vabs.begin();
|
for (const auto& snippet : snippets) {
|
||||||
it != vabs.end(); it++) {
|
if (!snippet.empty()) {
|
||||||
if (!it->empty()) {
|
|
||||||
// No need to call escapeHtml(), plaintorich handles it
|
// No need to call escapeHtml(), plaintorich handles it
|
||||||
list<string> lr;
|
list<string> lr;
|
||||||
// There may be data like page numbers before the snippet text.
|
// There may be data like page numbers before the snippet text. will be in
|
||||||
// will be in brackets.
|
// brackets.
|
||||||
string::size_type bckt = it->find("]");
|
if (pagenumre.simpleMatch(snippet)) {
|
||||||
if (bckt == string::npos) {
|
string pagenum = pagenumre.getMatch(snippet, 0);
|
||||||
m_hiliter->plaintorich(*it, lr, hdata);
|
if (!pagenum.empty()) {
|
||||||
|
m_hiliter->plaintorich(snippet.substr(pagenum.size()), lr, hdata);
|
||||||
|
lr.front() = snippet.substr(0, pagenum.size()) + lr.front();
|
||||||
|
} else {
|
||||||
|
m_hiliter->plaintorich(snippet, lr, hdata);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m_hiliter->plaintorich(it->substr(bckt), lr, hdata);
|
m_hiliter->plaintorich(snippet, lr, hdata);
|
||||||
lr.front() = it->substr(0, bckt) + lr.front();
|
|
||||||
}
|
}
|
||||||
richabst += lr.front();
|
richabst += lr.front();
|
||||||
richabst += absSep();
|
richabst += absSep();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user