如何通过Node.JS通过XMPP发送HTML格式的消息? [英] How do you send HTML formatted messages over XMPP with Node.JS?

查看:114
本文介绍了如何通过Node.JS通过XMPP发送HTML格式的消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题讨论了使用node-xmpp发送消息:
通过Node.js上的XMPP连接到Google Talk



任何人都知道如何获取HTML格式的消息。它们使用的库在一个名为ltx的节点模块中转义HTML。

XEP-0071 。确保您的HTML是有效的XML( XHTML ),然后像这样嵌入:

 < message> 
< body>哇,我和羡慕的绿色!< / body>
< html xmlns ='http://jabber.org/protocol/xhtml-im'>
< body xmlns ='http://www.w3.org/1999/xhtml'>
< p style ='font-size:large'>
< em> Wow< / em>,I& m< span style ='color:green'> green< / span>
与< strong>妒忌< / strong>!
< / p>
< / body>
< / html>
< / message>

请注意,纯文本也包含在无法呈现XHTML的客户端中。


This question discusses sending messages with node-xmpp: Connecting to Google Talk over XMPP on Node.js

Anyone know how to get an HTML formatted message. The library they are using escapes the HTML in a node module called ltx.

解决方案

See XEP-0071. Make sure your HTML is valid XML (XHTML), then embed like this:

<message>
  <body>Wow, I&apos;m green with envy!</body>
  <html xmlns='http://jabber.org/protocol/xhtml-im'>
    <body xmlns='http://www.w3.org/1999/xhtml'>
      <p style='font-size:large'>
        <em>Wow</em>, I&apos;m <span style='color:green'>green</span>
        with <strong>envy</strong>!
      </p>
    </body>
  </html>
</message>

Note that the plain text is also included for clients that can't render XHTML.

这篇关于如何通过Node.JS通过XMPP发送HTML格式的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆