-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add html and evernote formats #7
Open
jsparling
wants to merge
1
commit into
baniol:master
Choose a base branch
from
jsparling:add_html_and_evernote
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+120
−22
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.idea | ||
node_modules | ||
sass/.sass-cache | ||
deploy-settings.js | ||
deploy-settings.js | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
var dateFormat = require('dateformat') | ||
var escapeHtml = require('escape-html'); | ||
|
||
|
||
module.exports.convertToHtml = convertToHtml; | ||
module.exports.convertToEvernote = convertToEvernote; | ||
|
||
function convertToHtml(json){ | ||
var header = "<html><body>" | ||
var footer = "</body></html>" | ||
|
||
var body = "" | ||
body += "<h1>" + json[0].title + "</h1>" | ||
body += "<h3>" + json[0].author + "</h3>" | ||
json.forEach(function (item) { | ||
var parsedDate = new Date(item.timeInMs) | ||
timeFormatted = dateFormat(parsedDate, "mm/dd/yy, h:MM:ss TT"); | ||
body += "<p>" + item.location + ", " + timeFormatted + "</p>" | ||
body += "<p>" + escapeHtml(item.text) + "</p>" | ||
}) | ||
return header + body + footer | ||
} | ||
|
||
function convertToEvernote(json){ | ||
var hasContent = false | ||
var currentTime = dateFormat(new Date(), "UTC:yyyymmdd'T'HHMMss'Z'") | ||
|
||
var header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n \ | ||
<!DOCTYPE en-export SYSTEM \"http://xml.evernote.com/pub/evernote-export3.dtd\"> \n \ | ||
<en-export export-date=\"" + currentTime + "\" application=\"Evernote\" > \n \ | ||
<note> \n \ | ||
<title>" + json[0].title + "</title> \n \ | ||
<content><![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> \n \ | ||
<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\"> \n \ | ||
<en-note>"; | ||
var footer = "</en-note>]]>\n \ | ||
</content><created>" + currentTime + "</created><updated>" + currentTime + "</updated> \ | ||
<tag>kindle notes</tag> \n \ | ||
<note-attributes><author>jake sparling</author></note-attributes></note> \ | ||
</en-export>" | ||
|
||
|
||
var body= "" | ||
body += "<div><b style=\"font-size: 24px;\">" + json[0].title + "</b><br/></div>" | ||
body += "<div><span style=\"font-size: 18px;\">" + json[0].author + "</span><br/></div><br/><br/>" | ||
|
||
json.forEach(function (item) { | ||
var parsedDate = new Date(item.timeInMs) | ||
timeFormatted = dateFormat(parsedDate, "mm/dd/yy, h:MM:ss TT"); | ||
body += "<div><font color=\"#767676\">" + item.location.replace("- ", "") + " | " + timeFormatted + "</font><p/></div>" | ||
if(item.type !== 'Bookmark'){ | ||
hasContent = true | ||
body += "<blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\"><div>" + escapeHtml(item.text) + "</div></blockquote><p/>" | ||
} | ||
}) | ||
|
||
if(hasContent){ | ||
return header + body + footer | ||
} | ||
else { | ||
return null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when parsing a pdf file the line throws exception - item.location is undefined. I've handled this situation in the
getText
function (clipping.js
file)