Update post

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-27 10:54:11 -07:00
parent be52884226
commit 0cc8f18302

View File

@ -387,7 +387,7 @@ Add a spec:
```moonscript ```moonscript
describe "https://git.domain.abc", -> describe "https://git.domain.abc", ->
it "reverse-proxy's request to a gitea unix socket", -> it "reverse-proxy's a subdomain request to a unix socket", ->
socket = fname: "unixstreamsrvr.moon", dir: "/run/gitea", owner: "nobody" socket = fname: "unixstreamsrvr.moon", dir: "/run/gitea", owner: "nobody"
basepath = debug.getinfo(1).short_src\match"^(.*)/[^/]*$" or "." basepath = debug.getinfo(1).short_src\match"^(.*)/[^/]*$" or "."
seconds = 0.1 seconds = 0.1
@ -433,9 +433,11 @@ $ make test
## Bonus!: Issues We Ran Into Just Trying To Make This Post ## Bonus!: Issues We Ran Into Just Trying To Make This Post
1. `$host$request_uri` ### `$host$request_uri`
::: filename-for-code-block
`renderers/markdown.moon` `renderers/markdown.moon`
:::
```moonscript ```moonscript
dollar_temp = "0000sitegen_markdown00dollar0000" dollar_temp = "0000sitegen_markdown00dollar0000"
@ -458,4 +460,52 @@ $ make test
from the sitegen markdown renderer. Which makes my renderer a copy with from the sitegen markdown renderer. Which makes my renderer a copy with
some additions. some additions.
2. `$$ct` ::: filename-for-code-block
`spec/renderers_spec.moon`
:::
```moonscript
import escape_cosmo, unescape_cosmo from require "renderers.markdown"
it "escapes and unescapes adjacent cosmo selectors", ->
str = "$one$two"
escaped = escape_cosmo str
assert.same escaped,
"z000sitegen_markdown00dollar0000.1z000sitegen_markdown00dollar0000.2"
assert.same str, (unescape_cosmo escape_cosmo str)
```
### `$$ct`
```
z000sitegen_markdown00dollar0000.1
```
Because `.` is not a valid character for a variable name, when this string
is syntax-highlighted, it gets split, like this:
```
<span>z000sitegen_markdown00dollar0000</span>.1
```
The string is then 'unescaped', but because the string got split by the
closing `</span>` tag, it will no longer match the pattern and the
'unescape' fails.
The solution was to change the `.` in the dollar temp pattern to `_`, which is
a valid character in a variable name. Update the `$one$two` spec escaped
string.
::: filename-for-code-block
`spec/renderers_spec.moon`
:::
```moonscript
it "escapes and unescapes double dollar signs", ->
out = flatten_html render [[
```Makefile
$$name
```]]
assert.same [[<div class="highlight"><pre><span></span><code><span class="py-w"></span><span class="py-nv">$$name</span></code></pre></div>]], out
```