Skip to content

Commit

Permalink
Some small items before release (#431)
Browse files Browse the repository at this point in the history
* Make textarea and textfield not NPM private
* Fix typo in button image filename: outlind_with_icon.png
* Support <img> tags in static-urlify-readme-images script
  • Loading branch information
aomarks authored Aug 27, 2019
1 parent 3434543 commit 65bccda
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 1 addition & 2 deletions packages/textarea/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@
},
"publishConfig": {
"access": "public"
},
"private": true
}
}
3 changes: 1 addition & 2 deletions packages/textfield/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@
},
"publishConfig": {
"access": "public"
},
"private": true
}
}
15 changes: 10 additions & 5 deletions scripts/static-urlify-readme-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ const githubRaw =
`https://raw.githubusercontent.com/material-components/material-components-web-components`;

// Matches markdown image syntax like `![description](url "tooltip")`
const imageRegexp = /(\!\[.*?\]\()([^) ]+)(.*?\))/g;
const markdownImageRegexp = /(\!\[.*?\]\()([^) ]+)(.*?\))/g;

// Matches (markdown-compatible) HTML image syntax like `<img src="url">`
const htmlImageRegexp = /(<img .*?src=['"])(.+?)(['"])/g;

function isUrl(str: string): boolean {
try {
Expand All @@ -57,8 +60,8 @@ function main() {

for (const fileName of fileNames) {
const markdown = fs.readFileSync(fileName, 'utf8');
const updated = markdown.replace(
imageRegexp, (_, prefix: string, oldUrl: string, suffix: string) => {
const replacer =
(_: string, prefix: string, oldUrl: string, suffix: string) => {
if (isUrl(oldUrl)) {
// Only transform relative image paths, not fully qualified URLs.
return prefix + oldUrl + suffix;
Expand All @@ -72,8 +75,10 @@ function main() {
const relUrlPath = path.relative(mwcRepoRoot, absFilePath)
.replace(path.win32.sep, '/');
const newUrl = `${githubRaw}/${sha}/${relUrlPath}`;
return prefix + newUrl + suffix
});
return prefix + newUrl + suffix;
};
const updated = markdown.replace(markdownImageRegexp, replacer)
.replace(htmlImageRegexp, replacer);
fs.writeFileSync(fileName, updated, 'utf8');
}
}
Expand Down

0 comments on commit 65bccda

Please sign in to comment.