retypeapp / retype

Retype is an ✨ ultra-high-performance✨ static site generator that builds a website based on simple text files.
https://retype.com
Other
1.06k stars 204 forks source link

Invalid token found `,`. Expecting <EOL>/end of line. #622

Closed patricklafrance closed 1 year ago

patricklafrance commented 1 year ago

Hello!

Whenever my code block includes a React style attribute with a comma to separate style values, the Retype compiler display a warning:

WARNING: [guides\add-authentication.md:208,51] Invalid token found,. Expecting <EOL>/end of line.

image

Maybe I am getting too tired, but it seems like valid React/TSX code to me:

<div style={{ whiteSpace: "nowrap", marginRight: "20px" }}>
    ....
</div>

If I remove the comma, no warning:

<div style={{ whiteSpace: "nowrap" }}>
    ....
</div>

The code block language is set to tsx.

Thank you,

Patrick

geoffreymcgill commented 1 year ago

The {{ }} double opening and closing curly-braces is the default Retype templating syntax and that code is trying to be executed by the templating engine.

There are several options to either disable the templating engine or escape those code samples. Please see the following comment:

https://github.com/retypeapp/retype/issues/426#issuecomment-1273342318

The following sample escapes the entire code block:

{%{
```
<div style={{ whiteSpace: "nowrap", marginRight: "20px" }}>
    ....
</div>
```
}%}

Hope this helps.

patricklafrance commented 1 year ago

Oh got it. Yes that helps, thank you!