diff --git a/README.md b/README.md index a1b3b072..f00133df 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build Status](https://travis-ci.org/Khan/KaTeX.svg?branch=master)](https://travis-ci.org/Khan/KaTeX) [![codecov](https://codecov.io/gh/Khan/KaTeX/branch/master/graph/badge.svg)](https://codecov.io/gh/Khan/KaTeX) [![Join the chat at https://gitter.im/Khan/KaTeX](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Khan/KaTeX?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +![](https://img.badgesize.io/Khan/KaTeX/v0.9.0/dist/katex.min.js?compression=gzip) KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web. diff --git a/update-sri.js b/update-sri.js index 7277514f..3c966af3 100644 --- a/update-sri.js +++ b/update-sri.js @@ -19,6 +19,15 @@ function write(file, data) { Promise.all(process.argv.slice(3).map(file => read(file, "utf8") .then(body => { + // Replace size badge url + // 1 - url prefix: https://img.badgesize.io/Khan/KaTeX/ + // 2 - url suffix: /dist/katex.min.js?compression=gzip + const badgeRe = /(https:\/\/img\.badgesize\.io\/Khan\/KaTeX\/)(?:.+)(\/dist\/katex\.min\.js\?compression=gzip)/g; + body = body.replace(badgeRe, (m, pre, post) => { + return pre + version + post; + }); + + // Replace CDN urls // 1 - url prefix: "http…/KaTeX/ // 2 - opening quote: " // 3 - preserved suffix: /katex.min.js" integrity="…" @@ -26,9 +35,9 @@ Promise.all(process.argv.slice(3).map(file => // 5 - integrity opening quote: " // 6 - old hash: sha384-… // 7 - integrity hash algorithm: sha384 - const re = /((["'])https?:\/\/cdn\.jsdelivr\.net\/npm\/katex@)[^\/"']+(\/([^"']+)\2(?:\s+integrity=(["'])(([^-]+)-[^"']+)\5)?)/g; + const cdnRe = /((["'])https?:\/\/cdn\.jsdelivr\.net\/npm\/katex@)[^\/"']+(\/([^"']+)\2(?:\s+integrity=(["'])(([^-]+)-[^"']+)\5)?)/g; const hashes = {}; - body = body.replace(re, (m, pre, oq1, post, file, oq2, old, algo) => { + body = body.replace(cdnRe, (m, pre, oq1, post, file, oq2, old, algo) => { if (old) { hashes[old] = { file, algo }; }