Ed’s line should be a link (it is here).
The problem, though, is that the Discourse software doesn’t generally support this approach at present.
Ed’s line should be a link (it is here).
The problem, though, is that the Discourse software doesn’t generally support this approach at present.
Hey Shane,
It shows as an apparent link in Safari and Chrome, but there’s nothing connected to it – even when you inspect the source.
-Chris
Ah – I could have sworn it was working earlier.
Trying again:
Open this Scriplet in your Editor:
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
timer(“Start”)
YOUR CODE
— NOTE: The below shell scripts have nothing to do with the timer() handler —
set cmdStr to "perl -e ‘use Time::HiRes qw(time); print time’"
set timeStart to do shell script cmdStr
timer(“After First Shell Script”)
set timeStop to do shell script cmdStr
timer(“STOP”)
Maybe Discourse can’t handle html in a post?
Discourse forum software does not, in general, support HTML by users in a post. There are a few exceptions, like HTML tables (requires Admin to enable). Markdown is the primary formatting system for user posts:
The Discourse software does not allow non http/https URL schemes in URLs. When something like applescript://...
appears within a Markdown URL or an HTML href, Discourse strips it out.
There appears to be movement within the Discourse developers to relax this restriction in some future version of Discourse.
OK, what I would like to achieve is being able to select text in Script Debugger and run a script that grabs the selection (or the entire script) from the front window, and formats it for discourse, with all the color and style attributes, and drops it into an appleScript:// type link that displays the formatted script and when a user clicks on it, it will open the script in their script editor.
Is this doable with the current version of discourse, using HTML or Markdown?
We all share the same desire. For the time being, this is beyond our abilities for technical reasons having to do with the Discourse software. The Discourse folks are talking about fixing the issue where non-http/https URL schemes are filtered.
Once that issue is resolved, when we can generate applescript://
URLs. The final step will be to get the code which pretty-prints AppleScript for us to also generate the applescript://
URL string as well. I’m pretty confident I can make that JS/Ruby code work when the time comes.
It is all doable, except for the “AppleScript://” link. But you can use two separate scripts or macros to achieve the same:
For #1, see Keyboard Maestro Macro to Paste Script in Discourse Forum . You will just need to insert steps at the beginning to copy the SD selection.
For reference, here’s the forum markdown to format a script as AppleScript:
```applescript
-- your code here
It is best to convert any TABs used for formatting to spaces. Otherwise the forum software will use 8 spaces/TAB.
And please note that I have made AppleScript the default language for code blocks so even if you omit the applescript
specification, it will still work.
One script/macro to copy selection from SD and paste into forum post using markdown which will auto format for AppleScript (or any other supported language).
Right, and I have those that work in other contexts, but I’m not sure about discourse and markdown. The version I use requires style sheets.
Another script/macro to copy selected script (or script that is moused-over) from forum and paste into SD.
It really should be as simple to use for anyone as macScripter. You can’t expect users to install some proprietary software to make simple things work.
I thought I had clearly explained that. No CSS is required. Only Markdown, as shown in this post:
You speak of Keyboard Maestro as if it were some otherwise useless piece of software. It is quite the contrary. It is one of the most useful software apps/utilities I have ever owned. I use it countless times a day. If you are not familiar with it, I suggest you try the 30-day free trial – full version with no limitations.
I was simply offering a KM solution for those that want to use it. AFAIK, MacScripters.net is the only forum that offers the “applescript://” protocol, but maybe there are others.
Discourse forum software is open source, and supports custom plugins.
If you feel strongly about making it very easy for users to copy from the forum to SD, then you can do any of the following:
I was throwing my script snippets into TextWrangler, adding four spaces at the beginning and then doing a search & replace on \n with four spaces and \n.
Now that I’ve seen the four backticks trick, hopefully that won’t be necessary.
I didn’t get that impression. I think Ed was making a valid point that people shouldn’t have to install software - however valuable it might be for other uses - just to grab a script from this forum.
Thanks for the correction.
This info should really be more prominent, like in a pinned thread somewhere. I’ve been here almost since day 1 and I’ve only just learned how this is done.
In a couple of weeks time this thread will be buried and newcomers will be forever asking how it’s done.
Just an FYI, I’ve been copying and pasting script samples from the forum into scripts with no problem. (Although when that link becomes available, that will be good).
But today I tried to copy and paste the script into an email (Outlook) and while it looked OK on my end, the received message looked terrible and was unusable. (see below).
I don’t know if that’s an outlook issue, or a general email issue or what, but if there’s anything that can be done to avoid the issue or fix it in the forum, that would be good.
AEInteractWithUser() is in Carbon
use scripting additions property
returnCode : missing
value
on
showMessage:theMessage withTitle:boldBit textFrame:textFieldSize textMaxWidth:maxWidth withButtons:buttonsList
show the alert; needs to be done on the main thread
my
performSelectorOnMainThread:"showTheAlert:"
withObject:theAlert waitUntilDone:true
set
buttonNumber to
returnCode mod
1000
increase or decrease the second item’s numbers
to fit larger or smaller amounts of text
the ‘650’ here is the text field’s width
the ‘80’ is its height
set
theTextFieldSize to
{{0,
0},
{650,
80}}
set
buttonsToDisplay to
{“OK”,
“Five”,
“Four”,
“Three”,
“Two”,
“One”,
“Cancel”}
set
theButtonReturned to
its
showMessage:theMessage withTitle:theTitle textFrame:theTextFieldSize textMaxWidth:(650)
withButtons:buttonsToDisplay
Hi Ed
I’ve been caught out by the pasteboard adding formatting (often the wrong quotes marks, as well as line endings) so many times when copying from webpages that as a matter of habit I always paste a script into the editor and check it compiles first, then copy it from there directly before pasting it into anywhere else.