Skip to content

Commit

Permalink
rewrite video src links (#920)
Browse files Browse the repository at this point in the history
fixes #780
  • Loading branch information
joaomoreno authored Dec 15, 2023
1 parent 916fd91 commit b18c620
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ export abstract class MarkdownProcessor extends BaseProcessor {
contents = contents.replace(markdownPathRegex, urlReplace);

// Replace <img> links with urls
contents = contents.replace(/<img[^>]+src=["']([/.\w\s#-]+)['"][^>]*>/gm, (all, link) => {
contents = contents.replace(/<(?:img|video)[^>]+src=["']([/.\w\s#-]+)['"][^>]*>/gm, (all, link) => {
const isLinkRelative = !/^\w+:\/\//.test(link) && link[0] !== '#';

if (!this.baseImagesUrl && isLinkRelative) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/fixtures/readme/readme.branch.main.expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](https://github.com/username/repository/raw/main/SpellMDDemo2.gif#gh-light-mode-only)
<img src="https://github.com/username/repository/raw/main/images/myImage.gif">
<img src="https://github.com/username/repository/raw/main/images/myImage.gif#gh-light-mode-only">
<video src="https://github.com/username/repository/raw/main/videos/myVideo.mp4"></video>
<video src="https://github.com/username/repository/raw/main/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](https://github.com/base/SpellMDDemo2.gif#gh-light-mode-only)
<img src="https://github.com/base/images/myImage.gif">
<img src="https://github.com/base/images/myImage.gif#gh-light-mode-only">
<video src="https://github.com/base/videos/myVideo.mp4"></video>
<video src="https://github.com/base/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](https://github.com/base/SpellMDDemo2.gif#gh-light-mode-only)
<img src="https://github.com/base/images/myImage.gif">
<img src="https://github.com/base/images/myImage.gif#gh-light-mode-only">
<video src="https://github.com/base/videos/myVideo.mp4"></video>
<video src="https://github.com/base/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down
2 changes: 2 additions & 0 deletions src/test/fixtures/readme/readme.default.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](https://github.com/username/repository/raw/HEAD/SpellMDDemo2.gif#gh-light-mode-only)
<img src="https://github.com/username/repository/raw/HEAD/images/myImage.gif">
<img src="https://github.com/username/repository/raw/HEAD/images/myImage.gif#gh-light-mode-only">
<video src="https://github.com/username/repository/raw/HEAD/videos/myVideo.mp4"></video>
<video src="https://github.com/username/repository/raw/HEAD/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down
2 changes: 2 additions & 0 deletions src/test/fixtures/readme/readme.expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](https://github.com/username/repository/raw/master/SpellMDDemo2.gif#gh-light-mode-only)
<img src="https://github.com/username/repository/raw/master/images/myImage.gif">
<img src="https://github.com/username/repository/raw/master/images/myImage.gif#gh-light-mode-only">
<video src="https://github.com/username/repository/raw/master/videos/myVideo.mp4"></video>
<video src="https://github.com/username/repository/raw/master/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](https://gitlab.com/username/repository/-/raw/main/SpellMDDemo2.gif#gh-light-mode-only)
<img src="https://gitlab.com/username/repository/-/raw/main/images/myImage.gif">
<img src="https://gitlab.com/username/repository/-/raw/main/images/myImage.gif#gh-light-mode-only">
<video src="https://gitlab.com/username/repository/-/raw/main/videos/myVideo.mp4"></video>
<video src="https://gitlab.com/username/repository/-/raw/main/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](https://gitlab.com/base/SpellMDDemo2.gif#gh-light-mode-only)
<img src="https://gitlab.com/base/images/myImage.gif">
<img src="https://gitlab.com/base/images/myImage.gif#gh-light-mode-only">
<video src="https://gitlab.com/base/videos/myVideo.mp4"></video>
<video src="https://gitlab.com/base/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](https://gitlab.com/base/SpellMDDemo2.gif#gh-light-mode-only)
<img src="https://gitlab.com/base/images/myImage.gif">
<img src="https://gitlab.com/base/images/myImage.gif#gh-light-mode-only">
<video src="https://gitlab.com/base/videos/myVideo.mp4"></video>
<video src="https://gitlab.com/base/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down
2 changes: 2 additions & 0 deletions src/test/fixtures/readme/readme.gitlab.default.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](https://gitlab.com/username/repository/-/raw/HEAD/SpellMDDemo2.gif#gh-light-mode-only)
<img src="https://gitlab.com/username/repository/-/raw/HEAD/images/myImage.gif">
<img src="https://gitlab.com/username/repository/-/raw/HEAD/images/myImage.gif#gh-light-mode-only">
<video src="https://gitlab.com/username/repository/-/raw/HEAD/videos/myVideo.mp4"></video>
<video src="https://gitlab.com/username/repository/-/raw/HEAD/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down
2 changes: 2 additions & 0 deletions src/test/fixtures/readme/readme.images.expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](https://github.com/username/repository/path/to/SpellMDDemo2.gif#gh-light-mode-only)
<img src="https://github.com/username/repository/path/to/images/myImage.gif">
<img src="https://github.com/username/repository/path/to/images/myImage.gif#gh-light-mode-only">
<video src="https://github.com/username/repository/path/to/videos/myVideo.mp4"></video>
<video src="https://github.com/username/repository/path/to/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down
2 changes: 2 additions & 0 deletions src/test/fixtures/readme/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The status bar lets you quickly navigate to any issue and you can see all positi
![](./SpellMDDemo2.gif#gh-light-mode-only)
<img src="/images/myImage.gif">
<img src="/images/myImage.gif#gh-light-mode-only">
<video src="/videos/myVideo.mp4"></video>
<video src="/videos/myVideo.mp4#gh-light-mode-only"></video>

The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.

Expand Down

0 comments on commit b18c620

Please sign in to comment.