Applescript / Objective-C ScriptBridge: Checkboxes are deleted from HTML content

Recommended Posts

Hi, I noticed that when I read the HTML content (I also tried the ENML content - no difference) of a note and then reinsert it, that all the checkboxes are deleted.


Here is the Applescript code:



tell application "Evernote"    set theSelection to selection    set theNote to item 1 of theSelection    set theContent to HTML content of theNote    set HTML content of theNote to theContentend tell

The Result of this little code is no checkboxes any more.


I came across this when I used ScriptBridge in Objective-C (and thought that the more extensive HTML manipulation there resulted in an HTML error), but I checked it in Applescript to see whether there is a problem with the ScriptBridge or with the Evernote API. It is clearly an error in the Evernote API.


Anyone knows of this problem (and maybe how to avoid it if possible)?

Is there somewhere else where I should post this error with the Evernote team?


Share this post

Link to post

I don't sure whether it's your problem or not.

As written in ENML doc here:


Checkboxes in ENML are written as <en-todo> tag

<en-todo/>An item that I haven't completed yet.   <br/>  <en-todo checked="true"/>An completed item.


Which are difference from HTML <input type="checkbox"> tag 

<input type="checkbox" id="checkbox_id" value="value" /><label for="checkbox_id">An item that I haven't done</label>



I guess that you are using HTML <input type="checkbox"> tags which are not understood by Evernote.

Share this post

Link to post

Thanks Berrryboy and Laurent for your responses. 


Unfortunately ENML is not an option, because Evernotes own API only allows read only access to the ENML content. I really would like to have write access to ENML but the API just does not allow writing ENML. Only the HTML content is read/write with the local API (=Applescript) which I need to use for my project. 



BTW note that I am not creating the checkboxes myself in Applescript - I am just reading the HTML content (with checkboxes created in Evernote) from Evernote  and immediately write it back to Evernote.  



set theContent to HTML content of theNote -- reading HTML from Evernoteset HTML content of theNote to theContent -- writing HTML to Evernote


And I also tried reading ENML and then writing it back (to the HTML content which is the only read/write field) still the same effect.


I hope that the Evernote team will allow write access to ENML via Applescript - until then I guess I am out of luck.

Share this post

Link to post

Hi Mustafa,


Yes I've seen this (and it works), but I don't want to create new notes - I want to edit existing ones. The idea is that the program edits the ENML content of some specified existing notes. 


Is there a way to edit (or overwrite) the ENML code of existing notes? Something like:




tell application "Evernote"    set theSelection to selection    set theNote to item 1 of theSelection    set theContent to ENML content of theNote    -- here would be some code that changes the ENML variable theContent    set ENML content of theNote to theContent  -- unfortunately this step will produce an error. Is there a workaround?end tell 


Share this post

Link to post



Here is a concrete example


tell application "Evernote"	set newnote to create note title "Subject" with text "Notes"	append newnote html "<p/>hello"end tell

Share this post

Link to post

Thanks Mustafa, 


but this is an answer to a question on another topic. Appending html to an existing note is fine, but not enough. 


What I want to do is find specific regions in the note (labeled by keywords), and modify the HTML/ENML code there. Now programming this search and replace ain't the problem, but re-injectng the ENML into the existing note is not working. Basically what the app needs to do is read the note ENML, manipulate defined portions of the code and then save the ENML back into the note.


It works like a charm with HTML, but unfortunately using HTML leads to loosing some formatting options like checkboxes. 

Share this post

Link to post

Thanks. I thought so - but note that I don't want to append checkboxes. Actually my code doesn't even use checkboxes. 

I really would like to edit ENML via Applescript so that my code does not delete checkboxes (and maybe other ENML specific code) simply because I am forced to use the HTML code of the note. 

Share this post

Link to post

There's an open topic discussing this need.


As a work-around, you can export a note as ENML, use your favorite text processing routines to edit the ENML export file, then re-import it and delete the original. Definitely an ugly hack, but for editing one note, it's relatively quick.


If you want the script routines for handling this, let me know.

Share this post

Link to post

Thanks for the feedback. Appending checkboxes is not working as of now, we will fix that in an upcoming update. 


It isn’t work yet. Any news about a fix?



Share this post

Link to post