Description
Current status
The CodiMD editor automatically detects when the user is writing a table, by checking whether the first character on the line (after space) is a |
. In this table-editing mode, breaking the line has a non-standard effect, replaying the columns on the line below. For example,
| x <breaking a line here>
results in
| x |
| --- |
| |
Problem
This is great... except when you are writing code in a language whose syntax use bars at the beginning of lines! This is the case for ML-family programming languages (OCaml, SML) where pattern-matching clauses start with a |
, so having one at the beginning of a line is a really common occurrence.
For example, writing
```ocaml
let test = function
| [] ->
and breaking a line after the ->
will result in
```ocaml
let test = function
| [] -> |
| ----- |
| |
which makes OCaml programming fairly inconvenient within CodiMD.
Potential fixes:
Nice fix: the automatic detection of the table mode should be disabled when inside a code block.
Simple fix: you could also make it possible to opt out of table-edition detection for a given document. This is not ideal, but better than today.
Possible workaround: you could disable table-edition detection when the beginning of the line is |
(exactly one space before the bar). I suppose that you accept spaces before the bar because spaces sometimes occur naturally in Markdown syntax (in list items, etc.), but I don't think that any Markdown block syntax requires the use of a single space (lists use 2). This is much less discoverable than the other two solutions. This workaround would be acceptable for languages that use bars at the beginning of lines but are whitespace-insensitive (users could always add an extra space).