Jump to content

Welcome! You're currently a Guest.

If you'd like to join in the Discussion, or access additional features in our forums, please sign in with your Evernote Account here. Have an Evernote Account but forgot your password? Reset it! Don't have an account yet? Create One! You'll need to set your Display Name before your first post.

Photo

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


  • Please log in to reply
12 replies to this topic

#1 Palladion

Palladion

  • Pip
  • Title: Member
  • Group: Members
  • 30 posts

Posted 26 February 2013 - 04:07 PM

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 theContent
end 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?

 
 


#2 berryboy

berryboy

  • Pip
  • Title: Member
  • Group: Members
  • 42 posts

Posted 26 February 2013 - 04:59 PM

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

As written in ENML doc here: http://dev.evernote....t/core/enml.php

 

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.



#3 Laurent Sarrazin

Laurent Sarrazin

  • Title: Browncoat
  • Group: Developer Evangelist
  • 339 posts

Posted 26 February 2013 - 05:34 PM

You have to use ENML.

Actually, when you get the HTML content of your note, the checkboxes are represented by "embed" tags. 

But, according to ENML, embed tags are not allowed. So they're just ignored.



#4 Laurent Sarrazin

Laurent Sarrazin

  • Title: Browncoat
  • Group: Developer Evangelist
  • 339 posts

Posted 26 February 2013 - 05:37 PM

35 mins late... hem



#5 Palladion

Palladion

  • Pip
  • Title: Member
  • Group: Members
  • 30 posts

Posted 26 February 2013 - 07:12 PM

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. 

frm

 

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 Evernote
set 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.



#6 Mustafa

Mustafa

  • Title: Browncoat
  • Group: Evernote Employee
  • 348 posts

Posted 26 February 2013 - 08:38 PM

Did you try something like this ?

 

tell application "Evernote"
	
	create note with enml "<en-todo/> todo1"
	
end tell


#7 Palladion

Palladion

  • Pip
  • Title: Member
  • Group: Members
  • 30 posts

Posted 26 February 2013 - 09:22 PM

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
 

 



#8 Mustafa

Mustafa

  • Title: Browncoat
  • Group: Evernote Employee
  • 348 posts

Posted 26 February 2013 - 09:55 PM

Hi,

 

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


#9 Palladion

Palladion

  • Pip
  • Title: Member
  • Group: Members
  • 30 posts

Posted 26 February 2013 - 10:07 PM

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. 



#10 Mustafa

Mustafa

  • Title: Browncoat
  • Group: Evernote Employee
  • 348 posts

Posted 26 February 2013 - 10:13 PM

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



#11 Palladion

Palladion

  • Pip
  • Title: Member
  • Group: Members
  • 30 posts

Posted 26 February 2013 - 10:16 PM

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. 



#12 iNik

iNik

  • PipPip
  • Title: Alliance Lackey
  • Group: Members
  • 76 posts

Posted 04 March 2013 - 06:04 PM

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.



#13 CarlosSz

CarlosSz

  • Pip
  • Title: Member
  • Group: Members
  • 6 posts

Posted 16 January 2014 - 03:19 AM

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?

 

Thanks.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

Clip to Evernote