diff --git a/site.ts b/site.ts index ba396aa..ed798b2 100644 --- a/site.ts +++ b/site.ts @@ -181,18 +181,19 @@ site.process([".html"], (pages) => const { document } = page; document.querySelectorAll("pre code").forEach((code) => { - const matches = code.innerHTML.match(/\(\(\(\d+\)\)\)/g); + const matches = code.innerHTML.match(/\{\[\([^\)]+\)\]\}/g); if (!matches) return; + console.log(matches); let newHTML = code.innerHTML; matches.forEach((match) => { console.log( - `${match.replaceAll(/\(|\)/g, "")}`, + `${match.replaceAll(/[^\d]/g, "")}`, ); newHTML = newHTML.replace( match, - `${match.replaceAll(/\(|\)/g, "")}`, + `${match.replaceAll(/[^\d]/g, "")}`, ); }); diff --git a/site/blog/2025-06-09-nginix.md b/site/blog/2025-06-09-nginix.md index 6ec487a..5b42a5e 100644 --- a/site/blog/2025-06-09-nginix.md +++ b/site/blog/2025-06-09-nginix.md @@ -24,25 +24,25 @@ First, let's take a look at how ```c // in ngx_http_set_etag @ src/http/ngx_http_core_module.c:1681 -(((1))) -etag = ngx_list_push(&r->headers_out.headers); (((1))) +{[(1)]} +etag = ngx_list_push(&r->headers_out.headers); if (etag == NULL) { return NGX_ERROR; } -(((2))) +{[(2)]} etag->hash = 1; etag->next = NULL; ngx_str_set(&etag->key, "ETag"); -(((3))) +{[(3)]} etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3); if (etag->value.data == NULL) { etag->hash = 0; return NGX_ERROR; } -(((4))) +{[(4)]} etag->value.len = ngx_sprintf(etag->value.data, "\"%xT-%xO\"", r->headers_out.last_modified_time, r->headers_out.content_length_n) @@ -105,7 +105,7 @@ index 97a91aee2..2d07d71e6 100644 { ngx_table_elt_t *etag; ngx_http_core_loc_conf_t *clcf; - (((2))) + {[(2)]} + u_char *real, *ptr1, *ptr2; + ngx_err_t err; @@ -115,7 +115,7 @@ index 97a91aee2..2d07d71e6 100644 etag->next = NULL; ngx_str_set(&etag->key, "ETag"); - (((1))) + {[(1)]} - etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3); - if (etag->value.data == NULL) { - etag->hash = 0; @@ -131,14 +131,14 @@ index 97a91aee2..2d07d71e6 100644 + // gzip-compressed) should have different Etags. Thus, we also append + // content-length, which should be different when the response is compressed + -+ err = ngx_errno; (((3))) -+ real = ngx_realpath(clcf->root.data, NULL); (((4))) -+ ngx_set_errno(err); (((5))) ++ err = ngx_errno; {[(3)]} ++ real = ngx_realpath(clcf->root.data, NULL); {[(4)]} ++ ngx_set_errno(err); {[(5)]} + -+ #define NIX_STORE_DIR "@nixStoreDir@" (((6))) ++ #define NIX_STORE_DIR "@nixStoreDir@" {[(6)]} + #define NIX_STORE_LEN @nixStoreDirLen@ + -+ if (r->headers_out.last_modified_time == 1 (((7))) ++ if (r->headers_out.last_modified_time == 1 {[(7)]} + && real != NULL + && !ngx_strncmp(real, NIX_STORE_DIR, NIX_STORE_LEN) + && real[NIX_STORE_LEN] == '/' @@ -147,7 +147,7 @@ index 97a91aee2..2d07d71e6 100644 + // extract the hash from a path formatted like + // /nix/store/hashhere1234-pname-1.0.0 + // +1 to skip the leading / -+ ptr1 = real + NIX_STORE_LEN + 1; (((8))) ++ ptr1 = real + NIX_STORE_LEN + 1; {[(8)]} + + ptr2 = (u_char *) ngx_strchr(ptr1, '-'); + @@ -157,7 +157,7 @@ index 97a91aee2..2d07d71e6 100644 + return NGX_ERROR; + } + -+ *ptr2 = '\0'; (((9))) ++ *ptr2 = '\0'; {[(9)]} + + // hash + content-length + quotes and hyphen. Note that the + // content-length part of the string can vary in length. @@ -178,7 +178,7 @@ index 97a91aee2..2d07d71e6 100644 + - etag->value.data; + + ngx_http_clear_last_modified(r); -+ } else { (((10))) ++ } else { {[(10)]} + // outside of Nix store, use the upstream Nginx logic for etags + + etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3);