diff options
author | George Hazan <george.hazan@gmail.com> | 2024-03-24 20:28:54 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-03-24 20:28:54 +0300 |
commit | d5849fcb979c1d553643bc3b4d4b7f2f12cee03b (patch) | |
tree | 0c7bcb93e9ca0bde3879e316d3defdd721df97c4 /plugins/NewStory/src | |
parent | dedb8fbff8c6f38091623bd0833919088a176df7 (diff) |
fixes #4298 (NewStory: журнал считает слово после перевода строки продолжением ссылки)
Diffstat (limited to 'plugins/NewStory/src')
-rw-r--r-- | plugins/NewStory/src/templates.cpp | 22 | ||||
-rw-r--r-- | plugins/NewStory/src/utils.cpp | 10 |
2 files changed, 19 insertions, 13 deletions
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index a6b18f4ed6..471b7d1dfd 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -113,6 +113,15 @@ static void AppendString(CMStringW &buf, const wchar_t *p) buf.AppendFormat(L"<%ss>", pEnd);
p++;
}
+ else if (!wcsncmp(p, L"url]", 4)) {
+ p += 4;
+
+ if (auto *p2 = wcsstr(p, L"[/url]")) {
+ CMStringW wszUrl(p, int(p2 - p));
+ buf.AppendFormat(L"<a href =\"%s\">%s</a>", wszUrl.c_str(), wszUrl.c_str());
+ p = p2 + 5;
+ }
+ }
else {
buf.AppendChar('[');
if (*pEnd == '/')
@@ -152,9 +161,9 @@ CMStringW ItemData::formatHtml(const wchar_t *pwszStr) spRes = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&sp);
}
- CMStringW szBody;
- AppendString(szBody, wszOrigText);
+ CMStringW szBody(wszOrigText);
UrlAutodetect(szBody);
+ AppendString(str, szBody);
if (spRes) {
int iOffset = 0;
for (int i = 0; i < (int)sp.numSmileys; i++) {
@@ -163,24 +172,23 @@ CMStringW ItemData::formatHtml(const wchar_t *pwszStr) continue;
CMStringW wszFound(wszOrigText.Mid(smiley.startChar, smiley.size));
- int idx = szBody.Find(wszFound, iOffset);
+ int idx = str.Find(wszFound, iOffset);
if (idx == -1)
continue;
- szBody.Delete(idx, smiley.size);
+ str.Delete(idx, smiley.size);
CMStringW wszNew(FORMAT, L"<img class=\"img\" src=\"file://%s\" title=\"%s\" alt=\"%s\" />", smiley.filepath, wszFound.c_str(), wszFound.c_str());
- szBody.Insert(idx, wszNew);
+ str.Insert(idx, wszNew);
iOffset = idx + wszNew.GetLength();
}
CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)spRes);
}
- str += szBody;
str.Append(L"</body></html>");
- // Netlib_LogfW(0, str);
+ Netlib_LogfW(0, str);
return str;
}
diff --git a/plugins/NewStory/src/utils.cpp b/plugins/NewStory/src/utils.cpp index f9bb3cd252..f227578fd4 100644 --- a/plugins/NewStory/src/utils.cpp +++ b/plugins/NewStory/src/utils.cpp @@ -146,13 +146,11 @@ static int DetectUrl(const wchar_t *text) void UrlAutodetect(CMStringW &str)
{
for (auto *p = str.c_str(); *p; p++)
- if (int len = DetectUrl(p)) {
+ if (int len = DetectUrl(p)) {
int pos = p - str.c_str();
CMStringW url = str.Mid(pos, len);
- str.Delete(pos, len);
-
- CMStringW newText(FORMAT, L"<a href =\"%s\">%s</a>", url.c_str(), url.c_str());
- str.Insert(pos, newText);
- p = str.c_str() + pos + newText.GetLength();
+ str.Insert(pos + len, L"[/url]");
+ str.Insert(pos, L"[url]");
+ p = str.c_str() + pos + len + 11;
}
}
|