Can't open file via URL Handler

tim's Avatar

tim

25 Mar, 2021 03:57 AM

I'm having trouble getting basic URL Handler functionality to work on Big Sur (v.11.2.3) and the latest version of Marked 2 (2.6.5).

I open Terminal and try to open a file (foo.md) that exists in the current directory with the following command:

% open 'x-marked://open?file=foo.md'

The first time I do this, Marked 2 gets launched, but the file doesn't open. Subsequent tries with Marked 2 already launched do nothing and no error is generated. Is filename expansion supposed to work when typing the filename? It doesn't for me which is usually a sign of some kind of problem in my experience.

Dragging foo.md and dropping it on the Marked 2 icon opens the file as expected.

Any suggestions?

  1. Support Staff 1 Posted by Brett on 25 Mar, 2021 06:19 AM

    Brett's Avatar

    Are you providing a full path to the file? Marked doesn't receive the current directory via a url call, so specifying a full path is the only option (though tilde for home directory should work).

    - Brett

  2. 2 Posted by tim on 25 Mar, 2021 01:31 PM

    tim's Avatar

    Got it. I noticed that mention in the documentation after I saw your email. I also realized that the filename needs to be URL encoded which makes sense since it's a URL. Duh.

    So this works:
    % open 'x-marked://open/file=/Users/tim/Downloads/foo%20bar.md'

    Cool.

    I'm running this from a shell script, and I'd like to view that file with one of my custom styles applied to it. The style is called "Wheel of Life" and it appears in the Marked style menu. I can apply it manually in the interface with no problems, so I know that much works. The full path to that stylesheet is
    /Users/tim/Development/alg-data-analysis/resources/Wheel of Life.css

    I've tried a bunch of different permutations of the x-marked://style... calls, but I can't get anything to work. In fact, what I've been trying sends the Marked window to the background without doing anything to the style.

    Any suggestions?

    -Tim

    By the way, I absolutely love that this tool (Marked) is so hackable like this. I'm doing some data analysis in R, replacing some placeholder text with sed, and opening the resulting markdown file in Marked so I can generate a print quality PDF all from a shell script. So cool.

  3. Support Staff 3 Posted by Brett on 25 Mar, 2021 02:13 PM

    Brett's Avatar

    Apparently the function of the style method that should affect the
    frontmost window if no file is specified is broken. It works for me if
    you specify a filename or "all":

    x-marked://style/all?css=Wheel%20of%20Life

    That should work, let me know if it doesn't.

    -Brett

  4. 4 Posted by tim on 25 Mar, 2021 02:25 PM

    tim's Avatar

    Yep, that did it. Thanks for the assist.

    Are you still in Winona? I think I told you once that my in-laws are friends of your parents. My wife (Carlyn) and sister-in-law (Robin) remember you from back in the day at the Pleasant Valley youth group. They used to visit their grandparents (Carl and Louise Stallknecht) in the summers. Once things open up a bit more, I'd be happy to buy you a coffee sometime when we're visiting.

    -Tim

  5. Support Staff 5 Posted by Brett on 25 Mar, 2021 02:58 PM

    Brett's Avatar

    Sounds great. I have foggy memories of my church days, but I would
    probably need more context to actually remember anyone other than the
    girl I had a huge crush on. Who was not your wife. Her name was Abby :).

    -Brett

  6. 6 Posted by tim on 25 Mar, 2021 04:36 PM

    tim's Avatar

    It's a small world for sure. Your parents are actually planning to visit Robin in Montana this summer. (Carlyn and Robin's last name was Reinert back then. I can't remember how old they are compared to you, but they also have a younger sister named Mandy who was around too.)

    -Tim

  7. Support Staff 7 Posted by Brett on 25 Mar, 2021 05:46 PM

    Brett's Avatar

    I recall some Reinerts. But the ones I remember are far older than I am,
    so I probably never associated the name with anyone my age. But like I
    said, memories are foggy :).

  8. Support Staff 8 Posted by Brett on 27 Mar, 2021 01:32 PM

    Brett's Avatar

    I'm talking to my mother and she's reminding me who all these people are… is Robin's husband Ace? And what's your last name, because she's pretty certain she knows you, too.

    - Brett

  9. 9 Posted by tim on 27 Mar, 2021 04:26 PM

    tim's Avatar

    Yes, Robin and Ace Olsen are my siblings-in-law. My name is Tim Wilson.

  10. Support Staff 10 Posted by Brett on 27 Mar, 2021 08:41 PM

    Brett's Avatar

    Nice, yeah, my mom definitely knows you. She said nice things :).

    -Brett

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac