realworldocaml / mdx

Execute code blocks inside your documentation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suffix ellipses do not work after a whole-line ellipsis

emillon opened this issue · comments

Hi,

The following cram test does not work properly:

  $ cmd
  ...
  prefix ...

More specifically, the last line is matched literally so the following diff will be reported:

   $ cmd
  ...
-  prefix ...
+  prefix ignored part

While debugging this I discovered that there are two types of ellipses:

  • whole-line ellipses, just ... on the line (with optional whitespace around). These are parsed as Ellipsis and can match 0 or more lines.
  • suffix ellipses (introduced in #85): a line that ends with .... It is parsed as Output s (with ... in s) and matching is controlled in Output.equal. These can only appear at the end of a line.

The bug is demonstrated in the following utop session:

utop # Mdx.Output.equal [`Output "ignored"; `Output "prefix suffix"] [`Output "ignored"; `Output "prefix ..."];;
- : bool = true
utop # Mdx.Output.equal [`Output "ignored"; `Output "prefix suffix"] [`Ellipsis; `Output "prefix ..."];;
- : bool = false

In terms of solutions, ellipses are on the way out so it does not seem fixing.

A workaround if somebody is affected consists in replacing the suffix ellipsis by a whole-line one (or use postprocessing).