I occasionally export README.md
s to pdfs using grip
then wkhtmltopdf
. Recently I noticed that the generated pdf had links in markdown headings pointing to file locations in my own computer. I want either grip
to stop generating the href
within the exported markdown headings, or wkhtmltopdf
to stop trying to be smart and setting the links relative to paths in my computer. How can I do this?
I checked manual pages for wkhtmltopdf
and the help of grip
, but didn't find a clear option to disable this.
For completeness: The page source shows for example:
<h1 id="user-content-heading-1"><a class="heading-link" href="#heading-1">Heading 1<span aria-hidden="true" class="octicon octicon-link"></span></a></h1>
<p>Sample text1</p>
<h2 id="user-content-heading-2"><a class="heading-link" href="#heading-2">Heading 2<span aria-hidden="true" class="octicon octicon-link"></span></a></h2>
<p>Sample text2</p>
These hrefs are then converted by wkhtmltopdf
to a local file link, something like file://path/to/html
.
Since I couldn't find an easy way to get a patched QT for wkhtmltopdf
, I used awk
to find local hrefs and delete them: awk '{sub(/ href="(#[^"]+)"/,""); print $0}'
Pass the output of grip
through this and the problem is solved.