forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEvernote.js
80 lines (60 loc) · 2.33 KB
/
Evernote.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
"translatorID": "18dd188a-9afc-4cd6-8775-1980c3ce0fbf",
"label": "Simple Evernote Export",
"creator": "Volodymir Skipa",
"target": "enex",
"minVersion": "2.1.9",
"maxVersion": "",
"priority": 50,
"displayOptions": {
"exportNotes": true
},
"inRepository": false,
"translatorType": 2,
"lastUpdated":"2015-07-20 06:39:12"
}
/*
Evernote Export Translator
Copyright (C) 2012 Volodymir Skipa
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function doExport() {
Zotero.setCharacterSet("utf-8");
var evernoteString = "<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE en-export SYSTEM 'http://xml.evernote.com/pub/evernote-export.dtd'><en-export application='Zotero' version='"+Zotero.Utilities.getVersion()+"'>";
var item;
while (item = Zotero.nextItem()) {
var itemString = "<note>";
itemString += "<title>"+item.title+"</title>";
itemString += "<content><![CDATA[<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE en-note SYSTEM 'http://xml.evernote.com/pub/enml2.dtd'>";
/** NOTES **/
if (item.notes && Zotero.getOption("exportNotes")) {
itemString += "<en-note>";
for (var i in item.notes) {
itemString += "<div>"+item.notes[i].note+"<br/></div>";
}
itemString += "</en-note>]]>";
}
var dateToFormat = new String(item.date);
var evernoteDate = dateToFormat.replace(/-/g, "");
itemString += "</content><created>"+evernoteDate+"T000000Z</created>";
/** TAGS **/
for (var j in item.tags) {
itemString += "<tag>"+item.tags[j].tag+"</tag>";
}
itemString += "<note-attributes><source>web.clip</source><source-url>"+item.url+"</source-url></note-attributes></note>";
// replace "&" with "&"
itemString = itemString.replace(/\&/g, "&");
evernoteString += itemString;
}
Zotero.write(evernoteString);
Zotero.write("</en-export>");
}