elm-verify-examples
elm-verify-examples copied to clipboard
Generates invalid code when parsing backtics-separated code
When I run elm-verify-examples
with following example:
{-|
- some
- list
```
Basics.ceiling 123.45
|> Basics.toFloat
--> 124.0
```
-}
someFunction : ...
it generates following invalid code which doesn't even compile:
spec1 : Test.Test
spec1 =
Test.test "#someFunction: \n\n |> Basics.toFloat\n --> 124.0" <|
\() ->
Expect.equal
(
|> Basics.toFloat
)
(
124.0
)
If I indent same example with 4 spaces instead of using backticks it works, but since here I have example directly after a list, 4 spaces indentation can't be used as elm-format
will mangle that.
Sorry that this isn't working for you as you'd expected. Does it also not work with newlines in between? Do the three backticks format nicely on package.elm-lang.org ?
Do the three backticks format nicely on package.elm-lang.org ?
It formats normally with elm-doc-preview
. I'm not sure what you mean about newlines?
The problem seems to be that the unindented line within backtics-section is not detected by elm-verify-examples
.
This doesn't work with elm-verify-examples
, and generated code seems to imply that line Basics.ceiling 123.45
is ignored:
```
Basics.ceiling 123.45
|> Basics.toFloat
--> 124.0
```
This does work with elm-verify-examples
, but adding that unneeded indentation within backtics looks bad in generated documentation:
```
Basics.ceiling 123.45
|> Basics.toFloat
--> 124.0
```
I meant newlines here. There is no support for ``` in comments yet. Happy to accept a PR for adding support though.
{-|
- some
- list
-- <-- I meant adding a newline here and no ```
Basics.ceiling 123.45
|> Basics.toFloat
--> 124.0
-}
someFunction : ...
That syntax is not accepted by elm-format
. If there are 2 or more empty lines between list and following indented code-block, elm-format
will unindent the code-block and add backticks around it.
If there is only single newline then elm-format
will mangle the list and the code-block.
So this example with two empty lines:
...
- some
- list
Basics.ceiling 123.45
|> Basics.toFloat
--> 124.0
...
is changed by elm-format
to this:
...
- some
- list
```
Basics.ceiling 123.45
|> Basics.toFloat
--> 124.0
```
...
And this example with single empty line:
...
- some
- list
Basics.ceiling 123.45
|> Basics.toFloat
--> 124.0
...
is changed by elm-format
to this:
...
- some
- list
Basics.ceiling 123.45
|> Basics.toFloat
--> 124.0
...
Got it. Thanks for clarifying. Don't know when I'll get to this, but I definitelly think that we should start to support ```.