Jump to content

MarkdownTransform — Convert Markdown to other formats


Recommended Posts

  • 1 month later...
  • Replies 125
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Each Hotkey Trigger in the workflow corresponds to a different type of Markdown conversion: Markdown → BBCode Markdown → HTML Markdown → RTF Supported in conversion to RTF:

Ah, yes, I forgot to mention that just before that comment I updated the Workflow’s dependencies. Though I was expecting it to still need further fixing for Catalina, but great that it’s working for y

Headers were removing the line below, which in turn was messing up lists, which was causing your problem.   The new version fixes this, it should now work correctly for your case. I’ve also removed 

Posted Images

  • 2 weeks later...
  • 3 months later...

This workflow is fantastic! Thank you so much for putting it together.


There's one feature of Markdown (at least as it's implemented in FoldingText) for putting Comments inside {>> <<}. Usually, when Exporting, these comments are omitted. I really like leaving lots of notes for myself inside Comments while typing, but would like to be able to use this Workflow to copy the text without the Comments.


I'm not very well-informed about regexp. I thought maybe I could just replace any instance of {>> ... <<} with an empty ''. But I don't really know how to even do this. This was my attempted modification, which obviously doesn't work:

s = s.gsub /\{\<\<(\S.*?)\>\>\}/, ' '

Hopefully that shows what I'm aiming for? What did I get wrong here?


Thanks again!

Edited by Simolinic
Link to post

Thank you for the kind words.

On to your problem. You’re escaping too much: you don’t actually need to escape any of the characters, as they’re not special (the ones that are need to be there unescaped, anyway). You’re also trying to substitute for a space (' '), when you should be substituting by nothing (''). When you say (\S.*?), what you’re saying is “capture one non-whitespace character, followed by any character zero or more times, until it finds your closing condition”. You don’t need capturing, or the non-whitespace definition. You were on the right track, just needed to remove the extra stuff.

You said it should take into account text between {>> and <<}, but your example is showing something different (between {<< and >>}. I’ll take your first reference as guide. The line should read

s = s.gsub /{>>.*?<<}/m, ''
The m means you can have multi-line comments.

Keep in mind this solution substitutes by nothing (meaning “something empty”, as opposed to deleting), so if you have a comment by itself on a line, it will still leave an empty line.

On a tangent note, I recommend rubular to test out ruby regular expressions in real time.

Edited by Vítor
Link to post

Awesome! Thanks, Vitor.


Obviously I was silly to have flipped my << and my >>. I admit to a little bit of regexp dazzle, getting all turned around just trying to understand them at all.


Your new line is exactly what I needed! Thank you, my friend. :)

Link to post
  • 3 weeks later...


Added footnote support. Those aren’t really supported in BBCode, so there are some liberties with how they’re presented. You define them by setting something like [^1] in your text, and then again at the end of it (with a preceding blank line). The ones at the bottom should have no blank lines between them, as on conversion they’ll be added, as well as a line separating footnotes from the rest of the text.

If we have a text[^1] like this[^2].

With multiple lines and footnotes.

[^1] It will be converted.
[^2] To something a bit more readable.

If we have a text1 like this2.

With multiple lines and footnotes.

1 It will be converted.

2 To something a bit more readable.

Link to post

Yes, it would be somewhat trivial, but also somewhat time consuming. I, for one, believe you’re an isolated case in this, so I don’t intend to add support for it (the reason I’ve built this in the first place is that I find BBCode awful to write). I’ll gladly give you some help with transforming it, though. You should be able to do it with no understanding of ruby and some understanding of regular expressions.
It might also not be as simple as it looks at first. I took some liberties in interpreting certain transformations — transformations that can translate well from markdown to BBCode, but not the reverse. For example, in setting up headers, since they don’t exist in BBCode, I’ve picked a few of the markdown header sizes (from the available 6) and while converting what I do is make the text bold and increase its size to a number I’ve picked (from the available theoretically infinite1). Right now, if you’re unhappy with the sizes I’ve picked (or even the bold, as you might prefer them in italic, for example) its relatively easy to simply open the substitutions file, and change them to end up like you want2.

Now, how would we do the reverse? How would we define which combination of styles and sizes correspond to each header? Sure, it can be done, but it would take an insane amount os personal opinion and styling preference. I make it easy for you to edit the substitutions, but I also try to make very good defaults so you don’t feel a need to. Thats exponentially hard with the reverse system, because there are so many variations, no set of assumptions should satisfy most cases without the need for tweaking.

Markdown → BBCode means what you’ve used somewhere else could be transformed (and easily tweaked) without modifying the original content. BBCode → Markdown means dictating how you need to structure your content to get the desired result. It works the way it is currently because markdown has structure where BBCode only has styling declarations. A markdown header (likely) means you want your text bigger, but defining bigger text in BBCode does not mean you want a header. Structure → styling makes sense, styling → structure not so much.

1 Is there a size limit? Even if there is, it’s definitely higher than 6.

2 That’s a design decision present from the start. the workflow’s structure itself is influenced by this idea of making it easy to modify the substitutions that were driven by my opinions.

Link to post
  • 1 year later...
  • 5 months later...


  • Ever noticed that stupid non-breaking whitespace forum software automatically adds to your empty lines? Gone! That space could sometimes confuse the other transformations (particularly quotes), so hopefully they’ll now work more reliably.
  • Footnotes are now separated by a full horizontal line instead of dashes.
  • Inline code now has a background color.

Don’t worry if you see some tags in your preview. The forum software may not interpret them in the preview, but it will display them after posting.

Edited by Vítor
Link to post
  • 1 month later...
  • 5 weeks later...
  • 2 months later...
2 minutes ago, nikivi said:

Speaking of OneUpdater, it is really awesome. I wish more workflows implemented it.


Thank you for the kind words. I’m pretty confident OneUpdater isn’t that well known, so if you’d like to see it implemented more broadly (though it is meant to be versatile enough for you to implement it yourself in other people’s workflows), you should ask the developers to do so. If any has any questions, I’m available to answer.


2 minutes ago, nikivi said:

The only thing I am curious about though is why WebScreenshot updates so often? :D 


All updates are documented on the post. Long story short(er), it uses an external tool to upload the images to imgur. The original tool had a few issues, so I contributed upstream and worked with the author to fix them. As I found those issues with the tool and fixed them, WebScreenshot needed to be updated as well, naturally. Recently, however, as issues kept popping up for no discernible reason, I decided for various reasons the tool was just too broken and it wasn’t worth it to keep fixing it, so I changed it. With the change to a new tool, however, some implementation details changed, so I need to fix those as well. This new tool also as some minor issues I’m in the process of fixing. It’s better to have the workflow be made robuster regularly than just waiting and bottling up a lot of updates, especially since I have so many released workflows, sometimes they’re hard to keep track of.

Link to post

Oh, this makes sense then. Thank you for the updates.


There is an issue though. It seems the urls I get, have a space at the end of it, so for example, I make a screenshot and try and paste it here : 




The above, after pasting, will become this : 




I have to press delete every time after pasting. Can you help fix this issue? Thank you.

Edited by nikivi
Link to post
  • 3 weeks 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...