Jump to content

MarkdownTransform — Convert Markdown to other formats


Recommended Posts

Update.


New icon, new style for footnotes, and lists and code blocks now remove the lines above and below, because otherwise this forum leaves huge gaps of blank space.


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

Link to comment
  • 2 weeks later...

Update.


Removed support for code blocks starting with spaces or tabs. Fixed code blocks with backticks when they’re the first thing in the text. Other code improvements with no outside consequence.


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

Link to comment
  • 2 months later...

Re-installed this workflow today, as it handles a few things better than my Pandoc-based one. Couple of bugs/feature requests:

 

  1. Could you add support for level 4+ headers?
  2. The workflow also processes the contents of code blocks. Newlines get doubled and comments starting with # get turned into level-1 headers, both of which are undesirable.

 

Link to comment
4 hours ago, deanishe said:

Could you add support for level 4+ headers?

 

On these forums, regular text is size 4 and the maximum size rendered is 7 (8 or above is ignored and shown as 4). That’s the reason there’s only 3 levels. That said, I never use headers, so as long as regular text stays at 4 tell me which sizes you’d like for the headers (which markdown level translates to which BBCode size, and which should be bold (currently, they all are), and I’ll change it.

 

4 hours ago, deanishe said:

The workflow also processes the contents of code blocks. Newlines get doubled and comments starting with # get turned into level-1 headers, both of which are undesirable.

 

I agree and would also like to change that. I’ll have to think a bit as to how, though, since I likely won’t be able to keep using the regex method.

Link to comment
3 minutes ago, vitor said:

That said, I never use headers, so as long as regular text stays at 4 tell me which sizes you’d like for the headers

 

size=4 is fine for level-4 headers (####). Not sure I need more than that.

 

5 minutes ago, vitor said:

I likely won’t be able to keep using the regex method.

 

Should be doable, as long as you extract code blocks first and don't pass them through the rest of your regexes.

Link to comment

Updates:

  • Added support for #### headers (same size as regular text, but bolded).
  • Better handling of code blocks (no longer affected by markdown characters).


To update, download the latest version (same URL) or wait a few days (15 or less) and it’ll prompt you to on next usage, since it uses OneUpdater.
Link to comment
  • 3 weeks later...

Hey @vitor

 

Perhaps I am missing something but this workflow doesn't seem to work on converting multiple URLs.

 

For example, running the workflow on this line : 

 

I like [GitHub](https://github.com) and [Alfred](https://www.alfredforum.com/) 

 

Will get me this :

 

I like GitHub and [Alfred

 

It seems to break off. It happens 100 % of the times too.

Link to comment

Major update.


The Workflow is now called MarkdownTransform.


It continues to support Markdown → BBCode transformations, hopefully better and more reliably. Instead of a regex solution, it now uses Redcarpet and a custom renderer, tailored specifically to this forum.


It now also supports Markdown → RTF. This is ideal for writing emails in Markdown in most email apps.


See the top post for the new download link, or keep using MarkdownBulletin and eventually the auto-update mechanism will fire and download a transitional version that’ll then download MarkdownTransform on the next use.


This new version might not immediately work on your machine, due to your ruby version. The top post also addresses that.

Link to comment
1 hour ago, xilopaint said:

I know nothing about ruby. What's the best way to install the latest version without mess with the ruby's macOS installation?

 

Should I use Homebrew? Here I see that I can use RVM or rbenv (I don't have a clue about the difference).

 

If you already have Homebrew, simply brew install ruby and you’re good to go.

Link to comment
  • 2 weeks later...
  • 1 month later...

Hi vitor, perhaps I'm being blind but I cannot see what the actual version of Ruby is needed for this? Also, it would be great if you could add rbenv installed ruby support, you need to add: $HOME/.rbenv/shims/ to the path and then it should work (i have 2.4.2 installed via rbenv, 2.3.3 system ruby).

 

 

Link to comment
1 hour ago, iandol said:

it would be great if you could add rbenv installed ruby support

 

At the moment, I don’t intend to add direct support for ruby version managers. You can fix that easily, though. Go into the Run Scripts of the Workflow and alter the PATH there. It’s the first line.

Edited by vitor
Link to comment
12 minutes ago, iandol said:

Thanks vitor, would you be willing to make a generic path workflow variable we could edit so that we didn't lose the path every new new version? 

 

If I make a new version, sure. As it is the Workflow is pretty much feature-complete. Unless there’s a bug that needs fixing or it breaks with a new macOS release, it’s unlikely there’ll be a new release.

Link to comment

I've tried MerkdownTransform using Ruby V2.4.2p198 installed via rbenv and it fails (same error as if I use System Ruby 2.0.0p648 in Sierra):

 

Starting debug for 'MarkdownTransform'

[2017-11-27 23:42:37][trigger.hotkey] Processing output of 'action.script' with arg 'Here is a **test** text'
[2017-11-27 23:42:38][ERROR: action.script] /Users/ian/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/ian/Dropbox/Assorted/Alfred Settings/Alfred.alfredpreferences/workflows/user.workflow.B3480116-6231-4778-AD34-B08AA40F9A5D/_licensed/Redcarpet/gems/redcarpet-3.4.0/lib/redcarpet.bundle, 9): Library not loaded: /usr/local/opt/ruby/lib/libruby.2.4.2.dylib (LoadError)
  Referenced from: /Users/ian/Dropbox/Assorted/Alfred Settings/Alfred.alfredpreferences/workflows/user.workflow.B3480116-6231-4778-AD34-B08AA40F9A5D/_licensed/Redcarpet/gems/redcarpet-3.4.0/lib/redcarpet.bundle
  Reason: image not found - /Users/ian/Dropbox/Assorted/Alfred Settings/Alfred.alfredpreferences/workflows/user.workflow.B3480116-6231-4778-AD34-B08AA40F9A5D/_licensed/Redcarpet/gems/redcarpet-3.4.0/lib/redcarpet.bundle
	from /Users/ian/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/ian/Dropbox/Assorted/Alfred Settings/Alfred.alfredpreferences/workflows/user.workflow.B3480116-6231-4778-AD34-B08AA40F9A5D/_licensed/Redcarpet/gems/redcarpet-3.4.0/lib/redcarpet.rb:1:in `<top (required)>'
	from /Users/ian/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /Users/ian/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from ./bbcode:4:in `<main>'
[2017-11-27 23:42:38][action.script] Processing output of 'output.clipboard' with arg ''
[2017-11-27 23:42:38][output.clipboard] Processing output of 'action.script' with arg ''

 

I can test on another machine with High Sierra and Ruby V2.3 tomorrow see if I also get the Library not loaded: /usr/local/opt/ruby/lib/libruby.2.4.2.dylib (LoadError) 

Edited by iandol
Link to comment
10 minutes ago, iandol said:

I've tried MerkdownTransform using Ruby V2.4.2p198 installed via rbenv and it fails

 

I’m using that exact same version with ruby installed via Homebrew, and it works.


Simply adding it to the PATH may not be enough. I seem to recall that with rbenv you usually add a command to call it in the shell’s startup files. That command should be set in the Run Script as well.

Link to comment

I tried in High Sierra with the system ruby, and see the same issue with the (ruby 2.3.3p222) there as well as rbenv; that a dynamically linked library libruby.2.4.2.dylib cannot be found:

required dylib '/usr/local/opt/ruby/lib/libruby.2.4.2.dylib' not found, needed by '...Redcarpet/gems/redcarpet-3.4.0/lib/redcarpet.bundle'.  Did try: file not found '/usr/lib/libruby.2.4.2.dylib', file not found '/usr/local/lib/libruby.2.4.2.dylib', file not found '/usr/local/opt/ruby/lib/libruby.2.4.2.dylib'

I don't think this is a ruby version issue, but that the redcarpet that you bundle has a specific dylib dependency that is not met. I have RedCarpet gem installed locally, but it does not get used by your workflow. I tried searching in my rbenv install for 2.4.2 and cannot find libruby.2.4.2.dylib anywhere. rbenv uses ruby-build to install a ruby from source and I don't know why this is different than the homebrewed ruby. I need to use rbenv for other things, so don't want to install a third copy of ruby with homebrew. I can stick to your old workflow.

 

Anyway, thank you for all your excellent workflows!

Link to comment
15 hours ago, iandol said:

I have RedCarpet gem installed locally, but it does not get used by your workflow.

 

You can force it. Open the bbcode and/or rtf files in the Workflow and remove the $LOAD_PATH.unshift line.

 

15 hours ago, iandol said:

Anyway, thank you for all your excellent workflows!

 

Thank you for using them and for the kind words!

Link to comment

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