@10pearls/planer 中文文档教程

发布于 3年前 浏览 25 项目主页 更新于 3年前

planer

从电子邮件中删除回复引用。

lever,我们进入了简单的机器。 刨床去除一些材料以平整粗糙的表面,这似乎适用于平滑电子邮件以提取实际消息的模块。

这本质上是 Mailgun 出色的 talon python 库的 javascript 端口。 Planer 不做签名,尽管 talon 的那部分有一个节点端口

Installation

使用 npm 安装 planer(如果您希望它是全局的,请添加 -g):

npm install planer

Usage

重要:planer 接受注入的 <一个 href="https://developer.mozilla.org/en-US/docs/Web/API/Document">Document 对象来执行 html 解析。 您可以在浏览器中使用 window.document,或者在服务器上使用类似于 jsdom 的东西。 我们在测试套件中使用 jsdom

从纯文本电子邮件

planer = require('planer');

msgBody = "Reply!\n\nOn 15-Dec-2011, at 6:54 PM, Sean Carter <s.carter@example.com> wrote:\n> It's the ROC!\n>-Sean";
actualMessage = planer.extractFrom(msgBody, 'text/plain');
console.log(actualMessage); # "Reply!"

中提取消息: 从 html 电子邮件

planer = require('planer');

msgBody = 'Reply!\n<div>\nOn 11-Apr-2011, at 6:54 PM, Bob &lt;bob@example.com&gt; wrote:\n</div>\n<blockquote>\n<div>\nTest\n</div>\n</blockquote>';
actualMessage = planer.extractFrom(msgBody, 'text/html', window.document);
console.log(actualMessage) # "<html><body>Reply!\n</body></html>";

Contributing

中提取消息: 当然鼓励贡献。 请记住,源是 coffee 文件; /lib 中的 js 文件是为了方便而保留的。

为任何新功能编写测试。 在提交拉取请求之前,运行 npm run compile 将源代码编译成 javascript 文件。

MIT Licence

版权所有 (c) 2015 Leighton Wallace

特此免费授予任何获得副本的人许可 本软件和相关文档文件(“软件”),处理 在软件中不受限制,包括但不限于权利 使用、复制、修改、合并、发布、分发、再许可和/或出售 该软件的副本,并允许该软件是 提供这样做,但须满足以下条件:

上述版权声明和本许可声明应包含在所有 软件的副本或重要部分。

本软件“按原样”提供,不提供任何形式的明示或保证 暗示的,包括但不限于适销性保证, 适用于特定目的和非侵权。 在任何情况下都不得 作者或版权持有人对任何索赔、损害或其他 责任,无论是在合同、侵权或其他方面的行为中,由以下原因引起, 出于或与软件或使用或其他交易有关 软件。

planer

Remove reply quotations from emails.

At lever we are into simple machines. A planer removes some material to flatten out a rough surface, which seemed appropriate for a module that smooths out an email to extract the actual message.

This is essentially a javascript port of Mailgun's awesome talon python library. Planer does not do signatures, though there is a node port of that part of talon.

Installation

Use npm to install planer (add -g if you would like it to be global):

npm install planer

Usage

Important: planer accepts an injected Document object to perform html parsing. You can use window.document in a browser, or something akin to jsdom on the server. We use jsdom in our test suite.

To extract the message from a plain text email:

planer = require('planer');

msgBody = "Reply!\n\nOn 15-Dec-2011, at 6:54 PM, Sean Carter <s.carter@example.com> wrote:\n> It's the ROC!\n>-Sean";
actualMessage = planer.extractFrom(msgBody, 'text/plain');
console.log(actualMessage); # "Reply!"

To extract the message from an html email:

planer = require('planer');

msgBody = 'Reply!\n<div>\nOn 11-Apr-2011, at 6:54 PM, Bob &lt;bob@example.com&gt; wrote:\n</div>\n<blockquote>\n<div>\nTest\n</div>\n</blockquote>';
actualMessage = planer.extractFrom(msgBody, 'text/html', window.document);
console.log(actualMessage) # "<html><body>Reply!\n</body></html>";

Contributing

Contributions are of course encouraged. Keep in mind that the source is the coffee files; the js files in /lib are kept around for convenience.

Write tests for any new functionality. Run npm run compile to compile the source into javascript files before submitting a pull request.

MIT Licence

Copyright (c) 2015 Leighton Wallace

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文