GithubHelp home page GithubHelp logo

enml-js's People

Contributors

cowchimp avatar mrbkap avatar phuocnt0612 avatar wanasit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enml-js's Issues

enml.URLOfResource not defined

using your browser example I get the following:

enml.URLOfResource not defined

I also don't see this function defined in enml.js

<div> </div> is ignored

I expect

abc
def
is converted to abc\ndef, but

is converted to \n and \n is converted to " ", so newline is omitted. Could you check it?

function PlainTextOfENML(enml){

var text = enml || '';
text = text.replace(/(<\/(div|ui|li)>)/ig,"\n");
text = text.replace(/(<(li)>)/ig," - ");
text = text.replace(/(<([^>]+)>)/ig,"");
text = text.replace(/(\r\n|\n|\r)/gm," ");
text = text.replace(/(\s+)/gm," ");

return text;

}

'Getting Started' ENML to HTML Conversion

I was just testing this out with the 'Getting Started' note that Evernote creates for new users. The conversion from ENML to HTML is a little big messed up. Mainly seems to be closing DIVs before they should be causing strange spacing issues. This note is a very rich note with media and links and such so I thought it would be a good baseline test.

Here's the ENML for the note:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note style="background: #e6e6e6;font-family: 'Helvetica Neue',  Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif;color: #585957;font-size: 14px;line-height: 1.3;">
  <div style="height: 40px;">&nbsp;</div>
  <div style="max-width: 600px;padding: 25px 0px 0px 0px;background-color: #fff;margin: 0 auto;box-shadow: 0 0px 5px rgba(0, 0, 0, 0.2);">
      <div style="margin: 0px 25px;padding-bottom: 15px;">
      <en-media alt="Evernote Logo" type="image/png" hash="4914ced8925f9adcc1c58ab87813c81f"></en-media>
          <h1 style="color: #5fb336;margin: 0;margin-top: 15px;font-size: 20px;font-weight: normal;">Welcome to Evernote</h1>
          <p style="font-size: 16px;margin: 0px 0px 6px 0px;line-height: 1.4;">Put everything in one place - your notes, images, documents, web clips and audio notes. Find what you're looking for using our powerful search. Sync makes your notes accessible across your devices.</p>
      </div>
      <div style="margin: 0px 25px;font-size: 14px;color: #4d4b47;background-color: #e6f4f6;border: 1px solid #c1e8ec;padding: 0px 15px 8px;clear: both;">
          <h2 style="font-size: 16px;line-height: 1.25em;padding-top: 8px;margin-bottom: 6px;padding: 0;">Get Started</h2>
          <p style="margin: 8px 0;"><span style="font-weight: bold;">Create a New Note</span><br />Save your ideas, to-do lists, research, meeting notes, and more.</p>
          <p style="margin: 8px 0;"><span style="font-weight: bold;">Snap a Photo</span><br />Capture images that you want to remember&mdash;from business cards to wine labels to pictures of your family.</p>
          <p style="margin: 8px 0;"><span style="font-weight: bold;">Sync Notes and Find Them Anywhere</span><br />Search for anything, even text within images, on any computer, phone or tablet you use.</p>
          <p style="margin: 8px 0;">Need more inspiration? Check out our <a href="http://blog.evernote.com" style="text-decoration: none;color: #5fb336;">Blog</a></p>
          <p style="margin: 8px 0;">Have more questions? Check out our <a href="http://evernote.com/getting_started/" style="text-decoration: none;color: #5fb336;">Getting Started Guide &amp; Tutorial</a></p>
      </div>
      <div style="margin: 0px 25px;">
          <h2 style="font-size: 16px;line-height: 1.25em;padding-top: 8px;margin-bottom: 6px;">Install and use Evernote everywhere</h2>
          <ul style="padding: 0;margin: 0;">
              <li style="list-style-position: inside;padding-left: 4px;"><a href="http://evernote.com/evernote/" style="text-decoration: none;color: #5fb336;">Get Evernote</a> on your computer, phone and tablet.</li>
              <li style="list-style-position: inside;padding-left: 4px;">Install a <a href="http://evernote.com/webclipper" style="text-decoration: none;color: #5fb336;">Web Clipper</a> into your browser to remember interesting web pages.</li>
              <li style="list-style-position: inside;padding-left: 4px;">Email notes to your Evernote email address. Find it in your settings.</li>
          </ul>
      </div>
      <div style="margin: 0px 25px;">
          <h2 style="font-size: 16px;line-height: 1.25em;padding-top: 8px;margin-bottom: 12px;">Our products work great together. Try them all!</h2>
          <div>
              <div style="width: 100%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;display: block;min-height: 35px;">
                  <div style="width: 50%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;">
                      <a href="http://evernote.com/evernote/" style="text-decoration: none;line-height: 1em;color: #6f6f6f;position: relative; display: block;">
              <en-media alt="Evernote" type="image/png" hash="836fc57702fc08596a5b6d74e54b33cc" style="position:absolute;top:0;left:0;border-color:transparent;"></en-media>
                          <div style="width: 50%;min-width: 200px;margin: 0 0px 8px 0px;padding-right: 10px;line-height: .8em;margin-left: 34px;">
                              <span style="display: block;font-size: 14px;margin-bottom: .3em;font-weight: bold;">Evernote</span>
                              <span style="font-size: 12px;width: auto;">Remember everything </span>
                          </div>
                      </a>
                  </div>
                  <div style="width: 50%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;">
                      <a href="http://evernote.com/hello/" style="text-decoration: none;line-height: 1em;color: #6f6f6f;position: relative; display: block;">
              <en-media alt="Evernote Hello" type="image/png" hash="0e2d61050811670832d80ed457203343" style="position:absolute;top:0;left:0;border-color:transparent;"></en-media>
                          <div style="width: 50%;min-width: 200px;margin: 0 0px 8px 0px;padding-right: 10px;line-height: .8em;margin-left: 34px;">
                              <span style="display: block;font-size: 14px;margin-bottom: .3em;font-weight: bold;">Evernote Hello</span>
                              <span style="font-size: 12px;width: auto;">Remember people</span>
                          </div>
                      </a>
                  </div>
              </div>
              <div style="width: 100%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;display: block;min-height: 35px;">
                  <div style="width: 50%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;">
                      <a href="http://evernote.com/food/" style="text-decoration: none;line-height: 1em;color: #6f6f6f;position: relative; display: block;">
              <en-media alt="Evernote Food" type="image/png" hash="908ca278561900d6620da9a8b06ecbaf" style="position:absolute;top:0;left:0;border-color:transparent;"></en-media>
                          <div style="width: 50%;min-width: 200px;margin: 0 0px 8px 0px;padding-right: 10px;line-height: .8em;margin-left: 34px;">
                              <span style="display: block;font-size: 14px;margin-bottom: .3em;font-weight: bold;">Evernote Food</span>
                              <span style="font-size: 12px;width: auto;">Preserve your food memories</span>
                          </div>
                      </a>
                  </div>
                  <div style="width: 50%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;">
                      <a href="http://evernote.com/skitch/" style="text-decoration: none;line-height: 1em;color: #6f6f6f;position: relative; display: block;">
              <en-media alt="Skitch" type="image/png" hash="e9a7b8ccbfaeca2feebc51ccb1faa2b6" style="position:absolute;top:0;left:0;border-color:transparent;"></en-media>
                          <div style="width: 50%;min-width: 200px;margin: 0 0px 8px 0px;padding-right: 10px;line-height: .8em;margin-left: 34px;">
                              <span style="display: block;font-size: 14px;margin-bottom: .3em;font-weight: bold;">Skitch</span>
                              <span style="font-size: 12px;width: auto;">Draw attention</span>
                          </div>
                      </a>
                  </div>
              </div>
              <div style="width: 100%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;display: block;min-height: 35px;">
                  <div style="width: 50%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;">
                      <a href="http://evernote.com/clearly/" style="text-decoration: none;line-height: 1em;color: #6f6f6f;position: relative; display: block;">
              <en-media alt="Evernote Clearly" type="image/png" hash="c7dbb1ce10ff3dfe7c0a485d904d0d23" style="position:absolute;top:0;left:0;border-color:transparent;"></en-media>
                          <div style="width: 50%;min-width: 200px;margin: 0 0px 8px 0px;padding-right: 10px;line-height: .8em;margin-left: 34px;">
                              <span style="display: block;font-size: 14px;margin-bottom: .3em;font-weight: bold;">Evernote Clearly</span>
                              <span style="font-size: 12px;width: auto;">Distraction-free reading</span>
                          </div>
                      </a>
                  </div>
                  <div style="width: 50%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;">
                      <a href="http://evernote.com/peek/" style="text-decoration: none;line-height: 1em;color: #6f6f6f;position: relative;  display: block;">
              <en-media alt="Evernote Peek" type="image/png" hash="950bf3517b1e7f23bc40066853a23f7e" style="position:absolute;top:0;left:0;border-color:transparent;"></en-media>
                          <div style="width: 50%;min-width: 200px;margin: 0 0px 8px 0px;padding-right: 10px;line-height: .8em;margin-left: 34px;">
                              <span style="display: block;font-size: 14px;margin-bottom: .3em;font-weight: bold;">Evernote Peek</span>
                              <span style="font-size: 12px;width: auto;">Study smarter</span>
                          </div>
                      </a>
                  </div>
              </div>
              <div style="width: 100%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;display: block;min-height: 35px;">
                  <div style="width: 50%;min-width: 200px;float: left;margin: 0 0px 8px 0px;padding-right: 0px;">
                      <a href="http://evernote.com/penultimate/" style="text-decoration: none;line-height: 1em;color: #6f6f6f;position: relative;  display: block;">
              <en-media alt="Penultimate" type="image/png" hash="bb54c12582d7d1793fb860ae27fe9daa" style="position:absolute;top:0;left:0;border-color:transparent;"></en-media>
                          <div style="width: 50%;min-width: 200px;margin: 0 0px 8px 0px;padding-right: 10px;line-height: .8em;margin-left: 34px;">
                              <span style="display: block;font-size: 14px;margin-bottom: .3em;font-weight: bold;">Penultimate</span>
                              <span style="font-size: 12px;width: auto;">Beautiful digital handwriting</span>
                          </div>
                      </a>
                  </div>
              </div>
          </div>
      </div>
      <div style="margin: 0px 25px;clear: both;padding-bottom: 10px;">
          <h2 style="font-size: 16px;line-height: 1.25em;padding-top: 8px;margin-bottom: 0;">Go Premium, Get more</h2>
          <p style="margin-top: 2px;">Get additional features by upgrading to <a href="http://evernote.com/premium/" style="text-decoration: none;color: #5fb336;">Evernote Premium</a>.</p>
      </div>
      <div style="background: #f5f5f5;min-height: 16px;padding: 1px 30px;text-align: center;border-top: 1px solid #ebebeb;">
          <p style="color: #747474;line-height: 1.5em;"><a href="http://blog.evernote.com/" style="text-decoration: none;color: #747474;">Blog</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; <a href="http://www.evernote.com/market/" style="text-decoration: none;color: #747474;">Market</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; <a href="https://twitter.com/evernote" style="text-decoration: none;color: #747474;">Twitter</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; <a href="https://www.facebook.com/evernote" style="text-decoration: none;color: #747474;">Facebook</a></p>
      </div>
  </div>
  <div style="height: 40px;">&nbsp;</div>
</en-note>

Bug in BodyHashOfENMLHash?

Hi,

Thanks for your good work on this module.

I think there may be a bug in the function converting the hexadecimal hash for a resource to a binary hash. It doesn't seem to work properly for me when I create a map of the binary hash to the resource URL.

My workaround has been to:

(1) convert the binary hash received from the Evernote API (using the Evernote Node library) to a hex string by using the Node Buffer class << new Buffer(resource.data.bodyHash).toString('hex') >>;

(2) map the hex hash to the resource URL (instead of the binary hash); and

(3) comment out line 157, which runs the BodyHashOfENMLHash function on the hex hash pulled from the ENML

You might want to take a look at the hex hash to binary hash helper function and see if there's something there causing problems.

Thanks.

Wrong media hash

Following is my test file:

{
"guid": "4fa776ce-be89-4715-8b78-13c687fb62be",
"title": "無標題",
"content": "<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">

\n
<br clear="none"/>
\n
\n
<img alt="Evernote Logo" hash="4914ced8925f9adcc1c58ab87813c81f" type="image/png"/>\n

\n
\n
\n
",
"contentHash": "l\u000b�T#���\u0003\fH\u001b��a�",
"contentLength": 301,
"created": 1356396242000,
"updated": 1356400484000,
"deleted": null,
"active": true,
"updateSequenceNum": 85,
"notebookGuid": "a69f2542-0630-439f-ae75-2c115e9b9146",
"tagGuids": null,
"resources": [
{
"guid": "697af336-7530-4de7-ab70-e253afb650c0",
"noteGuid": "4fa776ce-be89-4715-8b78-13c687fb62be",
"data": {
"bodyHash": "I\u0014�ؒ_���Ŋ�x\u0013�\u001f",
"size": 2176,
"body": null
},
"mime": "image/png",
"width": 215,
"height": 54,
"duration": null,
"active": true,
"recognition": {
"bodyHash": "�X�Q��\u00153\u0002�ۖRh\u0010�",
"size": 411,
"body": null
},
"attributes": {
"sourceURL": null,
"timestamp": null,
"latitude": null,
"longitude": null,
"altitude": null,
"cameraMake": null,
"cameraModel": null,
"clientWillIndex": null,
"recoType": null,
"fileName": null,
"attachment": null
},
"updateSequenceNum": 86,
"alternateData": null
}
],
"attributes": {
"subjectDate": null,
"latitude": null,
"longitude": null,
"altitude": null,
"author": null,
"source": null,
"sourceURL": null,
"sourceApplication": null,
"shareDate": null
},
"tagNames": null
}

The output did not change from hash to source.

================ Example 2 (ENML) ================


Evernote Logo

================ Example 2 (HTML) ================

Evernote Logo

License?

Hi there, great work on this. If you have a moment could you assign a license so that it is clear if it can be reused?

Thanks,
Damian

en-media tag not closing for type 'image'

if there's an en-media tag that doesn't have type 'audio' or 'video', mediaTagStarted never gets set to true.

so then in the conditional sequence on line 217, the writer.endElement() function never gets called.

the end result is that if you have an image in an en-media tag, it throws off the proper nesting of divs because the outputted tag is still hanging open when writer.endElement() gets called on the div that encompasses it. that encompassing div doesn't get closed until the bottom of the doc, creating all sorts of weirdness.

happy to patch this myself, but i wanted to check to make sure that:

a) this was an issue for everyone, not just me.

b) the desired solution would be setting mediaTagStarted = true when the en-media tag is of type 'image'. an alternative would be calling writer.endElement() later even if mediaTagStarted = false.

Entity encoding issues

This library does not appear to be encoding entities correctly, for example with ampersand &, it will only encode the first occurrence.

&& -> &amp;&
&amp;& -> &amp;amp;&
&&& -> &amp;&&

The expected values for the three examples would be &amp;&amp;, &amp;amp;&amp;, and &amp;&amp;&amp;. Passing a mixture of encoded and non-encoded ampersands to the Evernote API returns an error.

screenshot from 2015-02-06 10 37 34

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.