Issue 853 in vacuum-im: Поддержка phpBB code

1 view
Skip to first unread message

vacu...@googlecode.com

unread,
Mar 30, 2015, 11:34:05 AM3/30/15
to vacuu...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Unknown Priority-Medium

New issue 853 by newc...@gmail.com: Поддержка phpBB code
https://code.google.com/p/vacuum-im/issues/detail?id=853

При получении сообщений процессор анализирует текст на наличие ссылок...
Было бы удобно добавить поддержку phpBB-тегов. В стиле

[b]1[/b] - жирный текст
[i]2[/i] - наклонный текст

Реализовать можно разными способами
1) Создать плагин поддержки phpBB
2) Внедрить готовый код в messageprocessor.cpp

Добавляем функцию

QString MessageProcessor::parseBB(const QString &AString) const
{
QString result = AString;
QMap<QString, QString> mDefaults;

mDefaults.insert("\\[b\\](.*)\\[/b\\]", "<b>\\1</b>");
mDefaults.insert("\\[i\\](.*)\\[/i\\]", "<i>\\1<\/i>");
mDefaults.insert("\\[u\\](.*)\\[\/u\\]", "<u>\\1</u>");
mDefaults.insert("\\[img\\](.*)\\[\/img\\]", "<img src=\"\\1\">");
mDefaults.insert("\\[url\\=(.*)\\](.*)\\[\/url\\]", "<a
href=\"\\1\">\\2</a>");
mDefaults.insert("\\[code\\](.*)\\[\/code\\]", "<code>\\1</code>");
int j = 0;
QMap<QString, QString>::iterator i;
for (i = mDefaults.begin(); i!= mDefaults.end(); ++i)
{
QRegExp rx = QRegExp(i.key());
rx.setMinimal(true);
result.replace(rx, i.value());
}

return result;
}

Затем правим

QString MessageProcessor::prepareBodyForReceive(const QString &AString)
const
{
QString result = Qt::escape(AString);
result = this->parseBB(AString); //Qt::escape(AString);

result.replace('\n',"<br>");
result.replace(" ","&nbsp; ");
result.replace('\t',"&nbsp; &nbsp; ");


return result;
}


Можно пользоваться).
С уважением Newcss

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

vacu...@googlecode.com

unread,
Mar 30, 2015, 3:02:46 PM3/30/15
to vacuu...@googlegroups.com
Updates:
Status: WontFix
Labels: -Type-Unknown Type-Enhancement

Comment #1 on issue 853 by potapov.s.a: Поддержка phpBB code
https://code.google.com/p/vacuum-im/issues/detail?id=853

Для этих целей в XMPP есть специальный стандарт XEP-71 XHTML-IM, он есть в
планах на реализацию.
Reply all
Reply to author
Forward
0 new messages