mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 03:08:40 +00:00
README: Add size badge (#1253)
* README: Add size badge Add a size badge showing size of gzipped katex.min.js * update-sri: Add code to replace size badge in readme * Change to use badge from shields.io instead My bad for assuming that badgesize.io supports https. Change to use the badge from shields.io which supports https. * More Unicode letters (#1260) This PR serves as a complement to PR #1232 by supporting some letters that are omitted from the Unicode range 1D400–1D7FF. * Include Bold-Italic fonts for \boldsymbol (#1257) * Include Bold-Italic fonts for \boldsymbol Fix #1228 * Update screenshots * README: Add size badge Add a size badge showing size of gzipped katex.min.js * update-sri: Add code to replace size badge in readme * Change to use badge from shields.io instead My bad for assuming that badgesize.io supports https. Change to use the badge from shields.io which supports https. * Use badgesize.io with https
This commit is contained in:
committed by
Kevin Barabash
parent
933a0ee5b5
commit
fe2dc1bedf
@@ -2,6 +2,7 @@
|
|||||||
[](https://travis-ci.org/Khan/KaTeX)
|
[](https://travis-ci.org/Khan/KaTeX)
|
||||||
[](https://codecov.io/gh/Khan/KaTeX)
|
[](https://codecov.io/gh/Khan/KaTeX)
|
||||||
[](https://gitter.im/Khan/KaTeX?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://gitter.im/Khan/KaTeX?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|

|
||||||
|
|
||||||
KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.
|
KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web.
|
||||||
|
|
||||||
|
@@ -19,6 +19,15 @@ function write(file, data) {
|
|||||||
Promise.all(process.argv.slice(3).map(file =>
|
Promise.all(process.argv.slice(3).map(file =>
|
||||||
read(file, "utf8")
|
read(file, "utf8")
|
||||||
.then(body => {
|
.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/
|
// 1 - url prefix: "http…/KaTeX/
|
||||||
// 2 - opening quote: "
|
// 2 - opening quote: "
|
||||||
// 3 - preserved suffix: /katex.min.js" integrity="…"
|
// 3 - preserved suffix: /katex.min.js" integrity="…"
|
||||||
@@ -26,9 +35,9 @@ Promise.all(process.argv.slice(3).map(file =>
|
|||||||
// 5 - integrity opening quote: "
|
// 5 - integrity opening quote: "
|
||||||
// 6 - old hash: sha384-…
|
// 6 - old hash: sha384-…
|
||||||
// 7 - integrity hash algorithm: 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 = {};
|
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) {
|
if (old) {
|
||||||
hashes[old] = { file, algo };
|
hashes[old] = { file, algo };
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user