Content-Length: 262717 | pFad | https://github.com/breakdance/breakdance/issues/3

D3 Links does not take <base ...> into account · Issue #3 · breakdance/breakdance · GitHub
Skip to content

Links does not take <base ...> into account #3

@joakimbeng

Description

@joakimbeng

Hi and thanks for a great lib!

Given an html document like this:

<!doctype html>
<html>
  <head>
    <base href="/pages/">
  </head>
  <body>
    <a href="page2.html">Hi</a>
  </body>
</html>

The actual location for page2.html is /pages/page2.html because there is a <base> element which sets the base url for all relative urls.

But when I compile it to markdown with Breakdance it yields:

[Hi](page2.html)

When it should instead be:

[Hi](/pages/page2.html)

I had a hard time tracking down the domain option to the breakdance-util package, and because it depends on state and options from the compiler I haven't figured out a good way to solve it.

My quick fix is to use cheerio myself like this:

const $ = cheerio.load('...the html above...');
breakdance($.html(), {domain: url.resolve(myUrl, $('base').first().attr('href'))})

This works but it would be better if Breakdance did support the <base> element, which I think it should.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/breakdance/breakdance/issues/3

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy