Save/Export to PDF and internal links

Victor Warner's Avatar

Victor Warner

06 Oct, 2013 01:04 PM

Purchaser of Marked 1 and Marked 2 and very *non* technical user.

I would like to know if Marked 2 will support internal links on export/save to PDF. At the moment it does not appear to do so.

I can see that in this Forum there has been discussion about this and that it is possible using a utility such as wkhtlmltopdf to support internal linking (see attached file as to what I mean by an internal link).

But knowledge is too limited to work out by wkhtmltopdf can support internal linking but Marked 2 cannot.

Is this something that Marked 2 can do (or will be coming)?

  1. Support Staff 1 Posted by Brett on 06 Oct, 2013 02:38 PM

    Brett's Avatar

    As mentioned in other discussions, it's a webkit bug, which is what Marked uses to display the preview and export PDFs. The bug has been fixed in the open source version of WebKit, but hasn't been integrated by Apple. When they do, it will work, but until then, not within Marked.

    wkhtmltopdf uses it's own patched version of WebKit, which I may have to resort to at some point.

  2. 2 Posted by Victor Warner on 07 Oct, 2013 08:44 AM

    Victor Warner's Avatar

    Thank you for the explanation.

  3. 3 Posted by potsky on 23 Oct, 2013 09:45 PM

    potsky's Avatar

    Perhaps available on Maverick with Safari 7 ?

    Currently downloading the upgrade, I'll try tomorrow but it is a pity that readers can not jump on page 367 in the PDF !

  4. 4 Posted by Victor Warner on 24 Oct, 2013 07:02 AM

    Victor Warner's Avatar

    I tried with Mavericks and latest version of Marked (2.1/777): no difference.

  5. 5 Posted by potsky on 24 Oct, 2013 07:22 AM

    potsky's Avatar

    What a shame...

  6. 6 Posted by potsky on 24 Oct, 2013 09:07 PM

    potsky's Avatar

    Ok, it is not so hard to achieve I think...

    I have downloaded wkhtmltopdf for mac os x from the googlecode page.
    I have saved my Marked document in HTML instead of PDF.

    Then I execute this in a Terminal this command ./wkhtmltopdf marked.html output.pdf
    I have something like this :

    (potsky@rb-macbookpro:~)$ cd Desktop/
    (potsky@rb-macbookpro:~/Desktop)$ cd
    (potsky@rb-macbookpro:~/Desktop/$ ./wkhtmltopdf ~/Desktop/ma
    MacBookPro.png  marked.html
    (potsky@rb-macbookpro:~/Desktop/$ ./wkhtmltopdf ~/Desktop/marked.html ~/Desktop/marked.pdf
    Loading pages (1/6)
    Counting pages (2/6)
    Resolving links (4/6)
    Loading headers and footers (5/6)
    Printing pages (6/6)

    Then when I open my output.pdf, I have all images, links in the TOC are ok and better... I have a TOC on a drawer in !!!

    3 problems :

    • the font of my css is not ok, perhaps I have to include it somewhere
    • the Marked rule Replace HR with page breaks does not work
    • keyword <!--BREAK--> does not work

    So :

    1. Could a Marked developer explain us how they convert the BREAK and how they manage font before feeding the safari converter ? Then I could code a small bash or python script to automate this process ?

    2. Why don't you include wkhtmltopdf in the Marked binary and use it instead the Mac OSX built in version ?

      • If it is a licence problem, perhaps could you include an option named Path to the pdf converter and use it instead ?

    :-) I am happy because there is a solution !

  7. Support Staff 7 Posted by Brett on 24 Oct, 2013 09:12 PM

    Brett's Avatar

    1. Marked converts hr’s and <!—BREAK—> by replacing it with a div with style "page-break-before:always". This only works when Marked is printing to PDF, it wouldn’t necessarily translate to an exported HTML file. You could easily add (or shell convert) your own divs and embed the styles directly, though.

    2. I’ve looked at solutions from Pandoc to wkhtmltopdf to wkpdf, but every time either size or license issues have been a problem. I’d consider adding an export processor, but there are so many options to consider when using those converters that it would require a lot of configuration on the user’s part. If you’re already capable of doing the conversion on the command line, it might just be prudent to export the html from Marked and have a Hazel process do the conversion via script…

    That being said, I’ll look back into wihtmltopdf and see if it’s a feasible option.

  8. 8 Posted by potsky on 25 Oct, 2013 02:55 PM

    potsky's Avatar

    Hi Brett,

    thank you very much, it works like a charm, I just create a build process in Sublime Text and PDF are now perfect with a TOC and with a footer/header !

    Just a curiosity : what do you use to convert the MD to HTML ? Pandoc ? If I could include this in my build keyboard shortcut, I will save a SAVE action in Marked :-)

  9. Support Staff 9 Posted by Brett on 25 Oct, 2013 02:59 PM

    Brett's Avatar

    I generally use Marked to do the conversion, but if I’m working from the command line I usually use MultiMarkdown or Kramdown.


  10. Support Staff 10 Posted by Brett on 25 Oct, 2013 02:59 PM

    Brett's Avatar

    Or did you mean _in_ Marked? Marked by default uses MultiMarkdown 4, with the option to use Discount instead.


  11. 11 Posted by potsky on 25 Oct, 2013 03:07 PM

    potsky's Avatar

    Sorry :-)
    I was talking about the Marked application...

    I would like to change our current workflow on Mac OS X :

    • I write some *.md in Sublime Text
    • When I save in ST, Marked is refreshed, perfect
    • I save as HTML in Marked
    • Then come back in ST to Build the PDF from the HTML generated by Marked

    I would like to have this workflow (especially for my colleagues) :

    • They write some *.md in Sublime Text
    • When they save in ST, Marked is refreshed, perfect
    • They Build the PDF in ST from the MD and not from the HTML generated by Marked

    The Build now commit, pull, merge and push in the git repository, send emails to alert people to read the updated document, etc...

  12. 12 Posted by potsky on 25 Oct, 2013 03:09 PM

    potsky's Avatar
  13. Support Staff 13 Posted by Brett on 25 Oct, 2013 07:55 PM

    Brett's Avatar

    Correct on MultiMarkdown 4.

    As far as the workflow goes, do you still want the output PDF to have Marked styles? If that’s the case, you’ll need to use a webkit-compatible PDF generator like wkhtmltopdf or wkpdf to do the build as a command line tool. You’ll need to export the CSS from your preferred or custom style and then include it via command line options with the CLI.

    Most of Marked’s features, such as Table of Contents and pagination tweaks aren’t available without Marked running. If your needs are simple, though, a wkhtmltopdf workflow with included CSS may work fine.

  14. 14 Posted by JR on 07 Apr, 2015 03:43 PM

    JR's Avatar

    I am wondering if this has been resolved. I'm using Marked Version 2.4.11 (895), and when I generate a paginated PDF, the links within the document are visible but do not correctly link. If it hasn't been fixed, is there a workaround that can be employed?

  15. Support Staff 15 Posted by Brett on 07 Apr, 2015 04:33 PM

    Brett's Avatar

    There has been no change to WebKit's handling of intra-document links at this point. The only workaround would still be to export to HTML and use wkhtlm2pdf, but the same problems with certain syntax not being carried over will exist.

  16. 16 Posted by Cai on 09 Aug, 2016 01:31 PM

    Cai's Avatar

    Yes, I would also like this. It's nice to put a table of contents at the start of PDF documentation created from markdown, but this is only useful with internal links.

  17. 17 Posted by Jon on 14 Oct, 2016 11:28 PM

    Jon's Avatar

    I too need internal links in pdfs. It's the only issue I have with an otherwise great app.

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