Skip to content

Links to static files are broken #639

Open
@mbostock

Description

@mbostock

Consider the following HTML:

<a href="test.png"><img src="test.png"></a>

The img[src] attribute is rewritten as expected, but the a[href] is not, so you get this:

<a href="test.png"><img src="./_file/test.png"></a>

We do rewrite a[href] attribute when there’s also a[download]:

https://github.com/observablehq/cli/blob/205d09b88907899a63fe9f4931715456d4055b6d/src/markdown.ts#L326

We don’t blanketly rewrite a[href] because it’s often used to link to another page, and pages don’t live in _file. But we should be able to tell whether a link is a link to a page or not (because we know how to resolve pages) — and for that matter, we want to normalize and rewrite links to pages anyway (to remove .md and to add .html for non-clean URLs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn’t working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions