Merge commit 'refs/pull/208/head' of github.com:Microsoft/vscode-vsce into pr/208

This commit is contained in:
Joao Moreno 2019-10-29 15:16:56 +01:00
commit 022b175b0c
No known key found for this signature in database
GPG key ID: 9494F5E6167A8E6B
4 changed files with 21 additions and 1 deletions

View file

@ -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;

View file

@ -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.

View file

@ -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.

View file

@ -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.