Skip to content

mdx wrongly adds ]} closing tags in mld after writing a value that ends with ]} #471

@giltho

Description

@giltho

Hello,

Take the following mld file:

{@ocaml[
type s = { x : int list }
]}


{@ocaml[
# let x = { x = [1; 2; 3] };;
]}

Applying ocaml-mdx modifies the second block into the following as expected

{@ocaml[
# let x = { x = [1; 2; 3] };;
val x : s = {x = [1; 2; 3]}
]}

The issue comes when one applies ocaml-mdx again, which yields:

{@ocaml[
# let x = { x = [1; 2; 3] };;
-val x : s = {x = [1; 2; 3]}
+val x : s = {x = [1; 2; 3]}]}
]}

i.e. mdx keeps adding ]} closing tags after the struct, because it ends with ]}. You can run dune test --auto-promote as many time as you want and it will keep adding closing tags. Here after a few iterations:

{@ocaml[
# let x = { x = [1; 2; 3] };;
-val x : s = {x = [1; 2; 3]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}
+val x : s = {x = [1; 2; 3]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}
]}

Unfortunately this is actively in the way of us using mdx, because there is no workaround that I can see. I'd welcome any pointer towards how to fix that issue and I'm happy to draft a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions