Comments (10)
The easiest method is by using Markdown's syntax ![alt text](imageurl)
but this requires your image is somewhere in the web and you have a valid URL pointing to it. This means that if the image is removed from the site it was hosted by, it will no longer appear in your note.
The usual way you do that in Evernote is by uploading the image (implicitly as an attachment) and put a reference to it in the note.
The plugin, being based on the textual interface of ST, does not have a direct way to interact with attachments. This could be a neat feature but needs a lot of work and I do not know if it would be worth it.
The Attach file
function of the plugin could come in handy though:
- you open the image file
ctrl+shift+p
Evernote: Attach current file to a note
- select the note you want to attach the image to
the attach_to_evernote_note
command has an optional insert_in_content
option (defaults to True) that will insert a reference to the attachment in the body of the note.
Unfortunately this does not currently work with images because ST3 previews them and does not set up a view from which one can retrieve the filename of the opened image so I think the previous instructions would just fail with an exception.
I'll think of a workaround, maybe a menu in the sidebar? a prompt for the filename?
from sublime-evernote.
Could it attach the image file to Notes automatically, if I use ![image](imageUrl)
?
And change the imageUrl to uploaded one?
That will preserve the images even if the source of image is removed or unavailable.
from sublime-evernote.
@metalbrick that's certainly possible but it requires a lot of new code.
I'll put this in the TODO list but I guess there are more urgent things and I have very little time at the moment.
If you wish to give it a go feel free to fork, create an "images" branch and submit a pull request.
It would be best if we discussed the specs here first though.
So, the technical difficulty with this is: the markdown parser needs to be modified to produce an <en-media type="image/jpeg" hash="HASH-HERE" />
tag; the HASH-HERE
part is a hash of the contents of the image and needs to be computed by the plugin; then the note needs to be updated with a new resource containing the downloaded data + the hash.
Puttin all this in the parser seems ugly as you are making it dependent on the logics about Evernote notes. Making it return a complicated structure holding the hashes and the data seems as ugly. Implementing this as a post-processing step is very error prone, you'll need to hook in an HTML parser as html2markdown does. Maybe all of this would be easier if we switched to a more sane md parser like mistune
but that requires work as well.
An additional problem is that the markdown source needs to be modified too: you cannot leave the ![image](imageUrl)
unmodified or the next time you update the note the whole process will be done again, duplicating the resource in the attachments.
I think the best solution would be to tradeoff in terms of automation and do the following:
Provide an "Insert image" command that will prompt for an URL / filename and do the necessary work, inserting the <en-media />
tag accordingly in the current cursor position.
This will work only on already created notes as it will update the note remotely with the new attachment. I already have plans for this to be implemented.
This way you can choose if you want to have the image embedded in the note or loaded from external sources.
Another feature in my todo list is a command to list and view attachments...
from sublime-evernote.
@oliverzy and @metalbrick I've implemented something in the attachments
branch.
If you could try and test it and give some feedback that would be awesome.
I intend to include these changes in next release but I need to test and document them properly.
from sublime-evernote.
It sounds awesome, I'll totally try these features and give some feedback.
from sublime-evernote.
It seems not to work for me, the picture would be fine in the file at first inserting, as this:
<en-media type="cab43657734bb42bfd1563c6595a939b" hash="image/jpeg"/>
but when sync to online, it would just preserved as an attachment but not a image to present, and display as a Paperclip instead of the picture itself.
Moreover, when it get edited online and fetched back again, the tag of attachment totally changed, it became of picture of the clip like this:
<en-media border="0" style="margin-top: -1px;" type="image/png" align="left" hash="0bcd03d2024bf5fdbd9925f560b931f9"/>
from sublime-evernote.
@metalbrick thanks a lot for trying it out!
I just pushed a commit solving the issue: I foolishly changed the order of the hash
and type
attributes but not the order of their values so the hash was containing the mime-type and viceversa.
It should work now. Can you confirm?
from sublime-evernote.
It work greatly now, I appreciate your nice work so much.
It would better if the process of uploading could be done background and not frozen the interface of sublime text.
from sublime-evernote.
That's a good idea, however it is trickier to implement than it might seem.
I could do the update asynchronously but then I would have to backtrack in a messy way if things go wrong (say an exception happens and the upload is not successful).
I'll think about it...
from sublime-evernote.
PR #29 has been merged with this new feature implemented.
It does not upload-download asynchronously but should work fine for reasonable files.
The download bit is done in memory for now but it would be a good idea to use the URL based method described here in the future.
from sublime-evernote.
Related Issues (20)
- unable to get token anymore...https://www.evernote.com/api/DeveloperToken.action HOT 12
- Missing dependency pygments HOT 4
- the creation of developer tokens is temporarily disabled HOT 2
- How to customize the markdown style? HOT 1
- Error msg: 'div' html tag with 'markdown' attribute HOT 11
- unable to open files
- Developer Token disabled HOT 1
- Unpack requires a bytes object of length 4 HOT 7
- div-tag appears after roundtrip HOT 2
- Cannot insert attachment: 'Module' object has no attribute 'parse' HOT 2
- The reference to the entity answer must end with a ; delimiter HOT 1
- use proxy didn't work
- Unpack requires a bytes object of length 1 HOT 9
- Evernote plugin error: unpack requires a bytes object of length 1 HOT 2
- Sublists (lists within lists) are not rendered correctly after export to evernote
- Any note submission or update returns "Illegal to contain comments in ENML" HOT 17
- Creation of developer tokens is temporarily disabled.
- Can't be used in Sublime Text 3 Build 4121 HOT 1
- connection reset by peer
- Evernote cannot perform the requested action: Action not allowed, permission denied or limits exceeded
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sublime-evernote.