Jump to content
vitor

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.
 

Share this post


Link to post

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.
 

Share this post


Link to post

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.

 

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post

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.

Share this post


Link to post

Update.


New icon.


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.

Share this post


Link to post

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.

Share this post


Link to post

@nikivi Can’t reproduce. That lines works fine here. Make sure you have the latest version and check the debugger.

Edited by vitor

Share this post


Link to post

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.

Share this post


Link to post

@vitor, 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).

Edited by xilopaint

Share this post


Link to post
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.

Share this post


Link to post

Update.

 

On the RTF conversion, have a 1rem bottom margin on paragraphs.


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.
 

Share this post


Link to post

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

 

 

Share this post


Link to post
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

Share this post


Link to post

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? 

Share this post


Link to post
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.

Share this post


Link to post

No problems if there is no update, no problem with the path :) — could you tell us the minimum required Ruby version (RedCarpet only needs 1.9.2)?

Share this post


Link to post
40 minutes ago, iandol said:

RedCarpet only needs 1.9.2

 

Ostensibly, yes. In practice, it’s failing to require in the default ruby version of Sierra. No idea why.

Share this post


Link to post

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

Share this post


Link to post
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.

Share this post


Link to post

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!

Share this post


Link to post
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!

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...