realworldocaml/mdx

Initial and trailing whitespace is inconsistently not preserved

panglesd opened this issue · 1 comments

Let me give a few examples (using docstring comment syntax) of the current behaviour:

# Original Corrected
1
{[
1+1 + 2
   ]}
{[1+1 + 2]}
2
{[   1+1 + 2   ]}
{[1+1 + 2   ]}
3
{[
  1+

  1 + 2     
     ]}
{[
  1+
  
  1 + 2     
]}
  • In 1, both initial and trailing spaces are removed, while in 2, only initial spaces are removed
  • the outputs on1 and 3 also feel very inconsistent...

While this is not a huge problem (one can consistently adopt a non-spaced {[content]} layout), I think it would be good to let the user decide, as for instance {[content]}, {[ content |} and

{[
   very long content
]}

make sense to use.

Moreover, I would like to introduce the use of mdx to check that the examples given in a library compile, and this is generating a lot of diff.

This can also interact with ocamlformat when parse-doctring is set to true!