-
-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jot tests fail on JavaScript #3195
Comments
So I had a look into this, and it looks like this is due to the difference in behaviour between the The relevant code is in the following function: // jot.gleam
fn inlines_to_html(html: String, inlines: List(Inline), refs: Refs) -> String {
case inlines {
[] -> html
[inline, ..rest] -> {
html
|> inline_to_html(inline, refs)
|> inlines_to_html(rest, refs)
|> string.trim_right
}
}
} If we look at the bad test, with javascript we go from
whereas in erlang we keep the space. I'm not sure what the desired behaviour is here though in order to fix it. Erlang REPL: ❯ erl
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit] [dtrace]
Eshell V14.2.5 (press Ctrl+G to abort, type help(). for help)
1> string:trim("<p><em> a ", trailing).
"<p><em> a " Node REPL: ❯ node
Welcome to Node.js v18.12.1.
Type ".help" for more information.
> "<p><em> a ".trimRight()
'<p><em> a' |
Good detective work! That is a rather annoying difference. 🤔 |
Yeah definitely not ideal. I'm not sure how/if we would want to resolve this difference. Is there precedence elsewhere in the standard library where there is/was different behaviour between JS and Erlang? |
We want them to behave the same here. |
In that case I have created a PR to rework the javascript behaviour to match the erlang behaviour. |
I have not investigated yet but seeing as it's pure Gleam it means there's some bug in the compiler or the standard library causing it here.
https://github.com/lpil/jot
The text was updated successfully, but these errors were encountered: