Set HTML document base url

Christian Kaula's Avatar

Christian Kaula

17 Apr, 2012 03:58 PM

It might be a good idea to set the document base url for the WebKit view. That way images that are referenced via relative URI would show up in the preview for Scrivener documents.


![this is an image][img]

[img]: images/someimage.jpg

The above does not work even though a file images/someimage.jpg exists relative to the Scrivener document. So right now I abuse the fact that Marked evaluates script tags and add something like this to my Scrivener document:

var ab = document.createElement('base');
ab.setAttribute('href', 'file:///path/to/scrienver/doc/');
document.head.insertBefore(ab, document.head.children[0]);

Since this is pretty hacky and I'm not sure script tags should be evaluated in the first place it would be nice to have this feature natively.


  1. Support Staff 1 Posted by Brett on 17 Apr, 2012 05:35 PM

    Brett's Avatar

    Done, it will be in the next version. Preview only, it won't export with the document to maintain portability.

    As a side note, I originally stripped ALL scripts tags not inside of a code block. I got a lot of blowback for that, given that a good portion of my users are quite capable with scripting and wanted to push the boundaries. Given that you can't visit external websites with Marked, I consider it safe enough, I guess.

  2. 2 Posted by Christian Kaula on 17 Apr, 2012 06:02 PM

    Christian Kaula's Avatar

    Cool stuff. Thanks a bunch.

  3. 3 Posted by clements.jb on 31 May, 2013 12:06 PM

    clements.jb's Avatar

    Can you confirm if this has been done? I recently purchased Marked, via MacAppsStore, but I've not been able to work out the appropriate 'syntax' (i.e. as above), to facilitate being able to view my Scrivener images, which I would like to be able to do.

    Can you advise?

  4. Support Staff 4 Posted by Brett on 31 May, 2013 12:28 PM

    Brett's Avatar

    The version currently in the Mac App Store does not include this improvement. I will contact you privately regarding beta testing the upcoming version if you're interested.

  5. 5 Posted by clements.jb on 31 May, 2013 12:40 PM

    clements.jb's Avatar

    I'm open to that. 

    ​The normal Scrivener workflow to pdflatex is working well form generally. 

    But there are times when printing off a PDF directly from Marked would be useful. 

    Is there any documentation of current workarounds for this issue in Scrivener? I couldn't find anything.  

    Sent from Mailbox for iPad

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


? 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