ENML translation

Hi all,
I spent almost 3hours on it today and still not able to do what I want.
I used to use a « Workflow » shortcut to save my reading notes to Evernote. It applies specific html syntax with name of the author, book’s title, page and my comment. The workflow convert this in rich text to send it to Evernote.
I now would like to use drafts to do this and if I want to keep my existing formatting I need tu replace html format to enml…
If I give you the html code could someone help me to translate it into enml?
Thanks a lot
Thomas

Perhaps the best thing to share would be your original Shortcuts shortcut?

Also, it is working, you could just set-up Drafts to send content to the shortcut as that may then easier for you to maintain in the future. What’s the driver for making it Drafts only?

Thanks for your answer.
The driver is using one app only to process quick notes and drafts is my favorite.
Your option would allow me to start in drafts so that could be ok but I prefer to keep the process in one app only as it is possible.

Please find the shortcut here https://www.icloud.com/shortcuts/3d9c979c0c03438a84cf7d0046af5e69

Your shortcut is based on capturing each item of data via input prompts. Drafts has equivalent prompts but I’m assuming you want to convert text in a draft into one or perhaps multiple entries in Evernote. Though if you do just want to do it via a prompt driven action with no draft content that would potentially be possible too.

What format is the data to be in within your draft? Single line per entry with delimiters and a specific order? Multiple lines in a specific order and a blank line to separate entries?

Could you provide an example of the layout of data you would expect in your draft, along with any information to identify what information is what in terms equivalent to the variables used in the shortcut.

The alternative is that a format is made up and that may well not match how you want to enter your data.

Hi,
Here is what I made until now.
https://actions.getdrafts.com/a/1YX
For now I need to capture my clipboard or right something in a new draft. Select all and cut, then activate the action above. The « send to Evernote part » is not working, that’s where I don’t understand why.
If I could also add the select all cut part before in the same action that would be even better.

The final result will be more or less like this
La parole est un sport de combat - Note de lecture
Each comment of the same book in the same Evernote note.

If you use ENML as your template output type in an Evernote step (docs), it’s up to you to make sure that the text created by the template is completely valid ENML. This means all the tags are already in place, any HTML entities converted, etc.

It’s an advanced feature, and probably not what you want. You probably want the Evernote step template output set to Markdown - then Drafts will run your text through the Markdown engine, which handles converting it to valid HTML/ENML.

Hi
It may seem like a whim but with markdown I loose color and I am not sure to be able to underline text.
I only need to translate a short part of automated text into valid ENML. Embedding each new draft into it as plain text sounds easy (I may be wrong).
I don’t understand how to do it even with Evernote support pages.
If I get a working code I could adapt it.

Well, it should work, as long as the text you are producing is complete, valid ENML. That’s the tricky part, because ENML is a XML format and Evernote strictly validates, so you have to be sure you are only using only HTML tags and attributes that are supported, and that you properly entify any necessary special characters, and all your tags are closed properly.

The ENML spec has details on what is and is not allowed.

In your case, it looks like you are using a lot of diacritical characters, which all need to be converted to HTML entities (e.g. é is é when entified for HTML). Drafts does not have a function for this, but there are Javascript libraries out there that could be loaded and used.

This seems not to worth it…
I use a « convert to RTF » step in Shortcuts. Is it something that could be done with drafts or JavaScript ?

The font style parameter isn’t supported (check the ENML DTD for details), so I reworked that.

It also looks like Insert Text isn’t respecting the disable smart quote option. So I’ve added an additional script step as a workaround.

That fixed the issues for my handful of tests, but I wasn’t using any accented characters as Greg noted about earlier.

Download the revision here - https://actions.getdrafts.com/a/1YZ

I really appreciate the time you’ve spent on this for me.

I tried your action but it’s not working neither and I get an « invalid ENML » message (for texts without any accented characters.

Could it be due to different settings in draft??

In any case, as I am French, I will use a lot of accented characters so the message Greg sent earlier made me realize that the easiest would be to forget color and use markdown only.

Many thanks again

T

Hello all,
The problem was only because of the "smart ponctuation " option from the iPhone. Each time I use quote marks the iPhone replace US quote marks by French quote marks and ENML does not support this.
The insert text action depends of this automation even if the right quote marks are originally written.
I managed to do what I wanted only by turning off the “smart ponctuation” option from the keyboard parameters on my iPhone.
Thanks again for your help @sylumer & @agiletortoise

1 Like

Hello everybody,
I up this post to know if someone can help me with the « cut » part.
I need an action that would copy all my draft then delete the text to be ready for another action.
In other means, is it possible to wright. JavaScript that would use a cut function of the clipboard with no selection needed as I always want the entire draft.
Thanks

To put the full text currently in the editor into the clipboard:

app.setClipboard(editor.getText());

I’m not sure what your use case is to re-use the draft, I would tend to recommend archiving or trashing the draft and starting a new one rather than overwriting an existing one - but if clearing it is really what you want to do:

editor.setText(“”);

After some prompts I end up with that “insert text action”

<br/><font size="12" color="#147191"><b>[[Auteur_button]]</b>, <u><i>[[Livre_button]]</i></u>, p[[Page_text]] : <br/>[[Type_button]] - </font>[[clipboard]]<br/>

I didn’t know how to use the text I just wrote and wrap it into that ENML code. I imagined needing to write text, cut it, and then write the draft again with the code up.
Is another option that would make the action simpler?