Jump to content

Markdown Transform — Convert Markdown to BBCode, HTML, and RTF


Recommended Posts

Major update (which you will likely not notice).

 

Switched to using MultiMarkdown, which means more transformations to HTML and a few more for BBCode and RTF (subscript).

 

Also removed support for footnotes in BBCode.


To update, download the latest version (same URL) or wait a few days and it’ll prompt you to on next usage, since it uses OneUpdater.

Link to comment
  • 5 months later...

Hi vitor,

 

first of thank you for all your workflows, I'm using many of them on a daily basis!

 

Unfortunately, I have some trouble with Markdown Transform. I'm working with Hook and Evernote and I would like to use your workflow to transform Hook-Links to rtf in Evernote (example: [pdf](hook://file/1yUfmPSUz?p=c2NpZWJvL0JpYmxpb3RoZWs=&n=Horn%20%E2%80%93%20Der%20geheime%20Krieg%20(2007).pdf#p=182). However, when I invoke your workflow on the selection, it returns "pdf" formatted as a Hyperlink (underlined), but it is not a link and I can't click on it. If I do the same in Apple Mail, it is a link, but I still can't click on it. In TextEdit, however, the workflow works fine. 

 

I'm on a MacBook Pro with Catalina.

 

Do you have any idea why that is?

 

Thanks a lot!

Link to comment
3 hours ago, Joaquim said:

first of thank you for all your workflows, I'm using many of them on a daily basis!

 

Glad to know!

 

However, as to your question, no idea. The RTF transformation is slightly hacky in the sense that it relies on simulating ⌘V to paste at the end. The apps where you’re saying it doesn’t work are apps I don’t use.

 

53 minutes ago, Joaquim said:

if I transform the md-link with another tool, it works.

 

What’s the tool? There aren’t many to do this conversion; perhaps I can understand the problem from seeing how they do it.

Link to comment

Thanks, @vitor!

 

1 hour ago, vitor said:

What’s the tool? There aren’t many to do this conversion; perhaps I can understand the problem from seeing how they do it.

 

I'm working with EverTool, which unfortunately is a paid app and thus not open source. It is designed for use with Evernote, but you can use it with any rich text editor, as it simply takes data from the clipboard and transforms it to rtf. (There are also other formatting options, too.)

 

However, I would much prefer a solution via Alfred, as it would integrate better with my workflow. Thus far, I have a workflow that gets the page index and label of the current document in Skim, combines it with the corresponding hook://-Link and outputs it as a markdown-Link (e.g. [p. 9](hook://file/1yUfmPSUz?p=c2NpZWJvL0JpYmxpb3RoZWs=&n=Horn%20%E2%80%93%20Der%20geheime%20Krieg%20(2007).pdf#p=1). With your workflow I'd be able to transform this to rtf and paste it to my note-taking app. This would work much faster than Dan Shefflers applescript, which does a similar thing and inspired me in the first place.

 

Link to comment
13 minutes ago, deanishe said:

Can you make a link and check the RTF that it puts on the clipboard with Clipboard Viewer?

 

Sure thing. Using my example, it gets me:

<meta charset='utf-8'>
    
    <p class="evertool-paragraph" style="font-size: 14px; color: black; font-family: 'Segoe UI', 'Source Sans Pro', Calibri, Candara, Arial, sans-serif, 'Microsoft JhengHei', sans-serif;"><a href="hook://file/1yUfmPSUz?p=c2NpZWJvL0JpYmxpb3RoZWs=&amp;n=Horn%20%E2%80%93%20Der%20geheime%20Krieg%20(2007).pdf#p=1" style="font-size: 14px; color: #2FA4E7; font-family: 'Segoe UI', 'Source Sans Pro', Calibri, Candara, Arial, sans-serif, 'Microsoft JhengHei', sans-serif;">p. 9</a></p>

    <br class="Apple-interchange-newline">

 

If I paste this to Evernote, it gets me, as expected, this: p. 9

 

I don't know why the Clipboard Content is HTML, while the output is RTF.

Edited by Joaquim
Link to comment
24 minutes ago, Joaquim said:

I don't know why the Clipboard Content is HTML, while the output is RTF.

 

Looking at their demo video, I see no indication they’re producing RTF. It seems highly unlikely, given the code syntax highlighting. It seems more likely that Evernote understands the pasted HTML and is parsing it.


MardownTransform supports HTML conversion. Have you tried that and pasting it into Evernote?

Link to comment
18 hours ago, vitor said:

MardownTransform supports HTML conversion. Have you tried that and pasting it into Evernote?

 

Evernote accepts pasted HTML. The problem is that the HTML generated by the workflow is put on the pasteboard as plain text, not as HTML.

Link to comment
21 hours ago, deanishe said:

Evernote accepts pasted HTML. The problem is that the HTML generated by the workflow is put on the pasteboard as plain text, not as HTML.


Guessing you’re referring to the NSPasteboardTypes. I’ve seen you mention something to that effect before but I’ve never worked with those. I’ll look into it. Not today, though.

 

Also guessing that to preserve the type I might need to paste by simulating ⌘V instead of using Alfred’s Copy to Clipboard Output, right?

Link to comment
1 hour ago, vitor said:

Also guessing that to preserve the type I might need to paste by simulating ⌘V instead of using Alfred’s Copy to Clipboard Output, right?

 

Yeah. Alfred puts everything on the pasteboard as plaintext (or RTF), so you'll need to populate the pasteboard yourself:

 

ObjC.import('AppKit');

function copyLink(url, title) {
    title = title || url;
    let html = `<a href="${url}">${title}</a>`;

    let pboard = $.NSPasteboard.generalPasteboard;
    pboard.clearContents;
    pboard.setStringForType(url, 'public.url');
    pboard.setStringForType(title, 'public.url-name');
    pboard.setStringForType(html, 'public.html');
    pboard.setStringForType(url, 'public.utf8-plain-text');
}

 

Link to comment
On 8/20/2021 at 12:46 PM, deanishe said:

Yeah. Alfred puts everything on the pasteboard as plaintext (or RTF), so you'll need to populate the pasteboard yourself

 

Hadn’t had the chance to look into this yet, but thank you for the code sample; it’ll speed it up when I do.

Link to comment
13 minutes ago, Chris Messina said:

How can I suppress the paragraph tags?


You might be better off with a link-specific workflow. Most Markdown converters are aimed at larger blocks of text and correspondingly wrap their output in block tags.

 

I mean, the workflow has no way of knowing if you've selected a completely standalone link or a link somewhere in the middle of a document, so it can't really know whether to wrap its output in <p> tags or not.


That way, you can also have a better link representation, too.

 

This is the code I use to generate links to messages in MailMate:

 

https://github.com/deanishe/CopyLink.mmBundle/blob/master/Support/bin/copylink

 

Apart from no block tags in the HTML and no explicit formatting in the RTF representation, it also puts the URL (and page title) on the clipboard, so you can also run things like Alfred's Universal Actions for URLs against it. 

Link to comment
  • 3 months later...
  • 3 months later...

Hi there, I love this workflow! I now have the opposite problem: I am using Craft.do and it seems to not allow pasting RTF but does accept Markdown! Does one exist or is there a way to make an RTF or HTML -> Markdown workflow? (at minimum to keep bold, italics, and links?). Thanks! Joe

Link to comment
39 minutes ago, biomarx said:

I love this workflow!

 

Thank you for the kind words.

 

39 minutes ago, biomarx said:

Does one exist or is there a way to make an RTF or HTML -> Markdown workflow?

 

It’s possible, though I don’t have a tool to recommend.

 

That won’t be added to the Workflow because it’s really niche and would essentially be a whole new Workflow. In almost a decade since the Workflow has existed, it’s the first time that has come up. Its purpose is to convert Markdown to BBCode for use in this forum; everything else (HTML and RTF) is icing on the cake.

 

46 minutes ago, biomarx said:

at minimum to keep bold, italics, and links?

 

Even if you only wanted to keep those tags, you’d still have to purposefully ignore all others so they don’t remain in the final result and you’d have to make deliberate decisions on formatting.

Link to comment
  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...