Skip to content
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

Bad parsing or ][ in block code #1137

Closed
zoggy opened this issue May 28, 2024 · 2 comments · Fixed by #1149
Closed

Bad parsing or ][ in block code #1137

zoggy opened this issue May 28, 2024 · 2 comments · Fixed by #1149

Comments

@zoggy
Copy link
Contributor

zoggy commented May 28, 2024

The following code is silently parsed incorrectly by odoc:

{@json[
{
  "string": "] [",
  "string2": "][",
}
]}

The problem is with the ][ sequence, but a space between ] and [ is parsed correctly. Using ]\[ does not solve the problem, as the \[is kept in generated html.

@panglesd
Copy link
Collaborator

panglesd commented May 29, 2024

Thanks for the report!
Indeed, the addition of the {[ ...][ ...]} syntax in ocaml-doc/odoc-parser#17 broke any codeblock containing ][...

Maybe a fix would be to have this syntax available only with a delimiter? That is, {delim[ ... ]delim[ ... ]delim} is a code block with an associated output, but {[ ... ][ ... ]} would be a normal code block containing "... ][ ...".

In the meantime, for your usecase, you can use a delimiter to avoid ][ be interpreted as an end to your code block:

{delim@json[
{
  "string": "] [",
  "string2": "][",
}
]delim}

(delimiters for odoc code blocks are similar to the OCaml {delim| ... |delim} for strings)

@zoggy
Copy link
Contributor Author

zoggy commented May 29, 2024

Ah, thanks !

jonludlam added a commit to jonludlam/opam-repository that referenced this issue Sep 13, 2024
CHANGES:

### Fixed

- Fix missing katex headers (@panglesd, ocaml/odoc#1096)
- Allow `][` in code blocks, fixing issue ocaml/odoc#1137 (@Julow, ocaml/odoc#1149)
  This was interpreted as "code blocks with result", which now mandates a
  delimiter: `{delim@lang[ code ]delim[ result ]}`
- Fix misprinting of type variables from ml files for OCaml 4.14 and later
  (multiple occurences of the same type variable could be named differently)
  (@Octachron, ocaml/odoc#1173)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants