dotnet / dotnet/docfx

[Bug] DocFX link validator doesn't accept ~ as a file link root

Open
#11,030 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
890
Avg merge
2h 11m
Merged PRs (30d)
10

Description

**Describe the bug**

I use `~` to set my image root, so I avoid "navigation" via ".." (folder up). Image-Tag or Include-Tag around the markdown files in different levels. So I like "~" to avoid folder-level issues.

I get a warning

> About.md: warning InvalidFileLink: Invalid file link:(~/assets/img/views/en/light/About.png).

The images are "copied" in the build step from my "test-project" to `assets/img/views`, my docfx.json (partly)

```json
{
"resource": [
...
{
"files": "**/*.png",
"src": "../App.Specs/screenshots/",
"dest": "assets/img/views",
"exclude": []
},
...
]
}
```

My Preferred way - can be used from everywhere

```markdown
![Image of AboutView](~/assets/img/views/en/light/About.png "Image of AboutView (light mode)")
```

The "Classic way" with ".." navigation

```markdown
![Image of AboutView](../../../assets/img/views/en/light/About.png "Image of AboutView (light mode)")
```

**To Reproduce**
Steps to reproduce the behavior:
1. Create a folder outside the docfx tree and add some images inside
2. Copy the png-files in build step of docfx to "_site" target
3. Create a markdown that reference the image with a ~-path
4. Build the html _site via `dotnet docfx build`
5. **BUG**: AboutView.md: warning InvalidFileLink: Invalid file link:(~/assets/img/views/en/light/About.png).

**Expected behavior**
The ~ should be a valid link, No `InvalidFileLink` warning in build

**Context (please complete the following information):**
- OS: Windows
- Docfx version: [e.g. 2.78.3]

**Additional context**
nothing

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.