Merge commit 'refs/pull/208/head' of github.com:Microsoft/vscode-vsce into pr/208
This commit is contained in:
commit
022b175b0c
4 changed files with 21 additions and 1 deletions
|
@ -384,7 +384,7 @@ export class MarkdownProcessor extends BaseProcessor {
|
|||
}
|
||||
|
||||
const markdownPathRegex = /(!?)\[([^\]\[]*|!\[[^\]\[]*]\([^\)]+\))\]\(([^\)]+)\)/g;
|
||||
const urlReplace = (all, isImage, title, link) => {
|
||||
const urlReplace = (_, isImage, title, link) => {
|
||||
const isLinkRelative = !/^\w+:\/\//.test(link) && link[0] !== '#';
|
||||
|
||||
if (!this.baseContentUrl && !this.baseImagesUrl) {
|
||||
|
@ -404,9 +404,26 @@ export class MarkdownProcessor extends BaseProcessor {
|
|||
|
||||
return `${isImage}[${title}](${urljoin(prefix, link)})`;
|
||||
};
|
||||
|
||||
// Replace Markdown links with urls
|
||||
contents = contents.replace(markdownPathRegex, urlReplace);
|
||||
|
||||
// Replace <img> links with urls
|
||||
contents = contents.replace(/<img.+?src=["']([/.\w\s-]+)['"].*?>/g, (all, link) => {
|
||||
const isLinkRelative = !/^\w+:\/\//.test(link) && link[0] !== '#';
|
||||
|
||||
if (!this.baseImagesUrl && isLinkRelative) {
|
||||
throw new Error(`Couldn't detect the repository where this extension is published. The image will be broken in ${this.name}. Please provide the repository URL in package.json or use the --baseContentUrl and --baseImagesUrl options.`);
|
||||
}
|
||||
const prefix = this.baseImagesUrl;
|
||||
|
||||
if (!prefix || !isLinkRelative) {
|
||||
return all;
|
||||
}
|
||||
|
||||
return all.replace(link, urljoin(prefix, link));
|
||||
});
|
||||
|
||||
const markdownIssueRegex = /(\s|\n)([\w\d_-]+\/[\w\d_-]+)?#(\d+)\b/g
|
||||
const issueReplace = (all: string, prefix: string, ownerAndRepositoryName: string, issueNumber: string): string => {
|
||||
let result = all;
|
||||
|
|
1
src/test/fixtures/readme/readme.expected.md
vendored
1
src/test/fixtures/readme/readme.expected.md
vendored
|
@ -21,6 +21,7 @@ The status bar lets you quickly navigate to any issue and you can see all positi
|
|||
[![Jump to issues](https://github.com/username/repository/raw/master/images/SpellMDDemo2.gif)](http://shouldnottouchthis/)
|
||||
[![Jump to issues](https://github.com/username/repository/raw/master/images/SpellMDDemo2.gif)](https://github.com/username/repository/blob/master/monkey)
|
||||
![](https://github.com/username/repository/raw/master/images/SpellMDDemo2.gif)
|
||||
<img src="https://github.com/username/repository/raw/master/images/myImage.gif">
|
||||
|
||||
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ The status bar lets you quickly navigate to any issue and you can see all positi
|
|||
[![Jump to issues](https://github.com/username/repository/path/to/images/SpellMDDemo2.gif)](http://shouldnottouchthis/)
|
||||
[![Jump to issues](https://github.com/username/repository/path/to/images/SpellMDDemo2.gif)](https://github.com/username/repository/blob/master/monkey)
|
||||
![](https://github.com/username/repository/path/to/images/SpellMDDemo2.gif)
|
||||
<img src="https://github.com/username/repository/path/to/images/myImage.gif">
|
||||
|
||||
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
|
||||
|
||||
|
|
1
src/test/fixtures/readme/readme.md
vendored
1
src/test/fixtures/readme/readme.md
vendored
|
@ -21,6 +21,7 @@ The status bar lets you quickly navigate to any issue and you can see all positi
|
|||
[![Jump to issues](images/SpellMDDemo2.gif)](http://shouldnottouchthis/)
|
||||
[![Jump to issues](images/SpellMDDemo2.gif)](monkey)
|
||||
![](images/SpellMDDemo2.gif)
|
||||
<img src="/images/myImage.gif">
|
||||
|
||||
The `spellMD.json` config file is watched so you can add more ignores or change mappings at will.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue