vitor Posted November 22, 2013 Share Posted November 22, 2013 Usage Convert Markdown to BBCode, HTML, or RTF via the Universal Actions. The result is pasted to the frontmost app. Configure the Hotkeys for faster triggering. ⤓ Install on the Alfred Gallery | Source vdesabou, Grug, devalias and 2 others 4 1 Link to comment
vitor Posted November 26, 2013 Author Share Posted November 26, 2013 Update. It now has files for updating (if you use Alleyoop, or something similar), made a correction to the img substitution, and added an option for images that send to a url. Link to comment
vdesabou Posted November 26, 2013 Share Posted November 26, 2013 Hi Vitor, When I use your workflow with my markdown file https://raw.github.com/vdesabou/alfred-spotify-mini-player/master/README.md, I get strange results. For example with: ## Settings * Configurable Search Scope: Only Starred playlist (by default) or All your playlists * Set max number of results. 50 by default * enable/disable Spotifious or Alfred Playlist * enable/disable ***Lookup this artist online*** * Install/Update of the library (see next section for explanations) ## First time use I get: ## Settings Configurable Search Scope: Only Starred playlist (by default) or All your playlists Set max number of results. 50 by default enable/disable Spotifious or Alfred Playlist enable/disable Lookup this artist online * Install/Update of the library (see next section for explanations) ## First time use Maybe I have something wrong in my md file, but the same file gives correct results with the workflow from Carlos-Sz (http://www.alfredforum.com/topic/1333-markdown-to-bbcode-17). Any idea? Thanks!! Link to comment
vitor Posted November 26, 2013 Author Share Posted November 26, 2013 Good catch, thank you. I’ve also fixed some other issues in the process. This updates has fixes for bold together with italic, lists with bold and italic in them (your issue), and lists and code blocks that start at the beginning of the text. Link to comment
vdesabou Posted November 26, 2013 Share Posted November 26, 2013 Good catch, thank you. I’ve also fixed some other issues in the process. This updates has fixes for bold together with italic, lists with bold and italic in them (your issue), and lists and code blocks that start at the beginning of the text. Great! But I think you forgot to check in the .alfredworkflow file, there is 404 error Link to comment
vitor Posted November 26, 2013 Author Share Posted November 26, 2013 But I think you forgot to check in the .alfredworkflow file, there is 404 error It was on the wrong directory. Should be working now. Link to comment
vdesabou Posted November 27, 2013 Share Posted November 27, 2013 It was on the wrong directory. Should be working now. Thanks! I have two other suggestions: - Handle # and ## titles - When I select my markdown text in my text editor and activate your workflow, it transforms the original file, so I have to cancel modification. Wouldn't it be possible to just have the BB code in the clipboard only? Or if not possible to open a new text file with the results, instead of modifying original? These are just ideas of improvement, your workflow is already very good Cheers Link to comment
vitor Posted November 27, 2013 Author Share Posted November 27, 2013 These are just ideas of improvement, your workflow is already very good Thank you. - Handle # and ## titles I’ve added three levels of headers, #, ##, and ###. - When I select my markdown text in my text editor and activate your workflow, it transforms the original file, so I have to cancel modification. Wouldn't it be possible to just have the BB code in the clipboard only? Or if not possible to open a new text file with the results, instead of modifying original? That’s easy to do, just dive into the workflow, double-click the Copy to Clipboard node, and deselect the Automatically paste to front most app option. I’m guessing most people only use it one way or another, for most of the time, although adding both options wouldn’t be that much trouble, if there’s demand for it. Link to comment
vdesabou Posted November 27, 2013 Share Posted November 27, 2013 That’s easy to do, just dive into the workflow, double-click the Copy to Clipboard node, and deselect the Automatically paste to front most app option. I’m guessing most people only use it one way or another, for most of the time, although adding both options wouldn’t be that much trouble, if there’s demand for it. Of course, I should have thought about that! Thanks for the headers, it is working perfectly for my use case now! Link to comment
vitor Posted December 3, 2013 Author Share Posted December 3, 2013 Update. Added support for quotes. Link to comment
vitor Posted January 21, 2014 Author Share Posted January 21, 2014 Update. Added support for strike through. Link to comment
deanishe Posted March 1, 2014 Share Posted March 1, 2014 (edited) Brilliant idea this. Unfortunately, this workflow doesn't work for me as I use Sublime Text and the Use OSX Selection feature only works with Cocoa apps. For anyone else with the same issue, I've created a modified version of the workflow that takes its input from the clipboard. Get it here. I've made a few other changes: The output is copied to the clipboard only and not pasted into the active app. A notification is shown to let you know the workflow has finished (seeing as it no longer pastes its results). I changed the behaviour of inline code (backticks) to add tags instead of bold and underline. This makes much more sense for me, as I use backticks for code. Trailing #'s are deleted from headers, so if, like me, you write # Heading # instead of just # Heading, the output will still be correct. I changed the bundle ID and removed the JSON files for updating, so my alternate version won't overwrite the original and vice versa. Edited March 1, 2014 by deanishe Link to comment
vitor Posted March 1, 2014 Author Share Posted March 1, 2014 (edited) I like some of your changes, so I’ve incorporated them in the original. I’ve also made some bug fixes that you might want to incorporate back to your version. Inline code is now set to a monospaced font. I was never truly happy with the bold and underlined solution, so thank you, I agree it makes much more sense like that. I’ve also adopted your change to headers, although in a slightly different way (I’ve changed the original lines to take into account those cases, instead of adding the new one). There are two bug fixes related to the horizontal rule. It’s no longer confused with italics, and an empty line with three spaces will no longer convert to an horizontal rule (this one was very specific, but it could still lead to undesired results). Edited March 1, 2014 by Vítor Link to comment
deanishe Posted March 1, 2014 Share Posted March 1, 2014 Gah! I was missing the \s in the header regexes (I tried to get it to work on one line, but couldn't). Thanks for the fixes! Link to comment
deanishe Posted March 2, 2014 Share Posted March 2, 2014 I've noticed a problem with this workflow when I'm trying to convert text containing non-ASCII characters. It works perfectly on the command line, but Alfred's Copy To Clipboard action does nothing. I'm afraid I don't know enough about text encoding in Ruby to be able to tell if there's a problem with the output (UTF-8, I'm assuming) or a bug in Alfred (I discovered the problem making a post about an Alfred text encoding bug). Any thoughts? Link to comment
deanishe Posted March 3, 2014 Share Posted March 3, 2014 Welp, I've had a prod at the Copy to Clipboard action with Python, and it works just fine with UTF-8 text, so I figure the problem lies with the output of the Ruby script. Link to comment
vitor Posted March 3, 2014 Author Share Posted March 3, 2014 Strange, since I’m actually taking that into account. I’ve encountered that encoding problem when building this workflow, and the first line of the ruby script is actually pointing that out and has a link to reference the used fix.It works without a problem, with me (I’m portuguese, so I use non-ASCII characters in regular typing as well, making that also a concern for me). Which characters are you having trouble with? And does it happen in both our versions? Link to comment
deanishe Posted March 3, 2014 Share Posted March 3, 2014 Yeah, I tested both versions. I figured you'd have tested it with non-ASCII as well. The character in question was ö. As I said, the script worked perfectly in Terminal. Weird. Link to comment
vitor Posted March 3, 2014 Author Share Posted March 3, 2014 Are you trying it in Sublime Text? What if you try it another editor? Doing it in this forum’s reply box works as it should; however, in Sublime it’s breaking `ö` into `o¨`. Link to comment
Carlos-Sz Posted March 3, 2014 Share Posted March 3, 2014 (edited) From my tests it seems Alfred (OSX selection and copy to the clipboard) is kind of breaking ö. Can you try to use a procedure to copy the result to the clipboard by yourself instead of letting Alfred doing that? Edited March 3, 2014 by Carlos-Sz Link to comment
deanishe Posted March 3, 2014 Share Posted March 3, 2014 (edited) I've tried it both ways (my modified Workflow grabs the clipboard contents with pbpaste because I use a keyword, not a hotkey). I just tried it in TextEdit (both ways) with the same result: Alfred doesn't place the results on the clipboard. For my part, I can't seem to get it to work with any non-ASCII characters. So far I've tried ü, ö, ñ and — (em-dash). By way of comparison, I used a Python script to print UTF-8 text to the Copy to Clipboard action and a bash script containing pbpaste -Prefer txt. Both worked perfectly. So I suspect it's a Ruby-Alfred misunderstanding. Edited March 3, 2014 by deanishe Link to comment
vitor Posted March 4, 2014 Author Share Posted March 4, 2014 I’ll look a bit more into it, but it seems like pbpaste is part of the problem, as it seems to be having some issues with it. For me it works well with the original version, but yours also fails. Odd issue. Link to comment
vitor Posted March 4, 2014 Author Share Posted March 4, 2014 Update. Fixes a bug related to urls directly preceded by other modifiers. Link to comment
deanishe Posted March 4, 2014 Share Posted March 4, 2014 I’ll look a bit more into it, but it seems like pbpaste is part of the problem, as it seems to be having some issues with it. For me it works well with the original version, but yours also fails. Odd issue. Confirmed. The problem was that I have the LANG variable set in Terminal, which was causing pbpaste to use UTF-8, but it isn't set when Alfred runs a script, so pbpaste was using C encoding. I changed pbpaste to LANG=en_GB.UTF-8 pbpaste and now it works. I have no idea why your version wasn't working for me yesterday, but it's working just dandy today. More than likely, I'd messed up the code, which was fixed by the update. Sorry for the erroneous bug report. Link to comment
vitor Posted March 4, 2014 Author Share Posted March 4, 2014 No problem, glad it’s working now. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now