Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gregor.hoch

macrumors member
Original poster
Apr 5, 2011
51
6
I am trying to use qlmanage, a terminal command to perform Quick Look actions, to open a html file and jump to a specific location in the file (anchor). In the browser, I would just use file:///[LOCATION]/test.html#jump but that does not work with qlmanage. Below is an example that works with qlmanage and some attempts to jump to the anchor, which are not working.

Note that Quick Look itself can jump to anchors in html files. When I open links from emails with anchors, quick look jumps to the correct location. Hovering over the link in an email shows this:
'x-apple-ql-file:///[LOCATION]/test.html?/[LOCATION]/#jump

Thanks!



Works

Code:
/usr/bin/qlmanage -p '~/Desktop/test.html'

Doesn't work

Code:
/usr/bin/qlmanage -p '~/Desktop/test.html#jump'
/usr/bin/qlmanage -p 'file:///[LOCATION]/test.html#jump'

Example HTML File

Code:
        <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="chrome=1"></head>
        
        <body>
        	<h1>Heading</h1>
        	<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        	<p id="jump">
        		jump here
        		<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
        	<p>
    
    </body>
 
Hovering over the link in an email shows this:
'x-apple-ql-file:///[LOCATION]/test.html?/[LOCATION]/#jump

Doesn't work

Code:
/usr/bin/qlmanage -p '~/Desktop/test.html#jump'
/usr/bin/qlmanage -p 'file:///[LOCATION]/test.html#jump'
Your non-working examples don't follow the same syntax as your email example. I've hilited the difference in red.

I'm pointing this out for logical reasons, not because it works.


When I try the first example command, I get multiple warnings and errors output. They all say there's no such file. This is after creating the test.html file on my Desktop, and after running the posted command that works. (As run on Snow Leopard.)

Did you get any error messages? What did they say?


Your example HTML file is also missing a <!DOCTYPE>, and the <html> tags. My test file had them.
 
Last edited:
I am getting the same error message. Something like file not found.

I guess I double pasted with the highlighted syntax example. Sorry for that. But I never got 'x-apple-ql-file' to work with qlmanage anyway.

Thanks for your trials!
 
I am getting the same error message. Something like file not found.

When posting questions, it's always a good idea to mention error messages. It's an even better idea to post the actual text of the complete error message.
http://www.mikeash.com/getting_answers.html


I'll also point out that qlmanage isn't really "a terminal command to perform Quick Look actions". It's a debugging and management tool. That's what it says in its man page. It should also be obvious because the QL window that shows the preview has the word "DEBUG" in its title.

I mention this because it's quite possible you'll have to write a command-line tool in order to get what you want. To that end, you should probably start by reading the Quick Look Programming Guide.

Just because a tool can be used for X doesn't mean it was designed for X, nor that it can accomplish all possible variations on X.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.