markdown-pdf icon indicating copy to clipboard operation
markdown-pdf copied to clipboard

Literal URLs should be rendered once

Open chdsbd opened this issue 8 years ago • 5 comments

Literal URLs in a markdown file will be rendered twice.

http://example.com is rendered as http://example.com (http://example.com)

This seems redundant.

chdsbd avatar Apr 26 '16 20:04 chdsbd

I agree.

This happens because the URL in parentheses is added using CSS to any <a href="something">.

Implementation idea: Drop the CSS. Instead use remark to parse the markdown into mdast, transform Link nodes into Link nodes (followed by Text nodes with the href-in-parentheses if the title and url differ), render the tree to HTML again, render to PDF as usual. Harder, but neater. This could be done by a separate module though.

anko avatar Apr 26 '16 21:04 anko

I builded a workaround. Create a custom CSS file:

@media print {
    a[href]:after {
        content: "" !important;
    }

    abbr[title]:after {
        content: " " !important;
    } 
    body {
        font-size: 0.625em;
    }

}

Include this file via options.cssPath in js, or via --css-path in shell.

Zadagu avatar Jul 12 '16 10:07 Zadagu

We just encountered the same issue. In our case an extra CSS file is not really an option here. Any suggestions?

claudiobmgrtnr avatar Jan 22 '18 14:01 claudiobmgrtnr

@Zadagu Thanks for the idea!

I've added that:

a[href]:after {
        content: "" !important;
    }

To my CSS and it helped. I think, issue could be closed as that is just a CSS problem

XAMelleOH avatar Mar 06 '18 08:03 XAMelleOH

Thankfully this also fixes [LInk Name](https://link.to.something)

iamjoeker avatar May 01 '19 00:05 iamjoeker