hosseinmd / prettier-plugin-jsdoc

A Prettier plugin to format JSDoc comments.
MIT License
228 stars 29 forks source link

Pipe characters within backticks treated as markdown table columns #187

Open JamieMason opened 1 year ago

JamieMason commented 1 year ago

Thanks @hosseinmd for this excellent plugin, it's a huge time saver 🙌🏻

I noticed a small issue I wanted to share with you (I have a workaround which is to just use OR in place of || in my example for now).

Steps to reproduce

Format a markdown table containing a pipe | character which is inside backticks - to represent code:

/**
 * | Scenario       | Pseudocode             | Outcome               |
 * | :------------- | :--------------------- | --------------------- |
 * | `Ok || Err`    | `pipe(Ok, or(Err))`    | `Ok`                  |
 * | `Err || Ok`    | `pipe(Err, or(Ok))`    | `Ok`                  |
 * | `Err1 || Err2` | `pipe(Err1, or(Err2))` | `Err2`                |
 * | `Ok1 || Ok2`   | `pipe(Ok1, or(Ok2))`   | `Ok1` (first Ok wins) |
 */

Expected Behaviour

The table remains formatted, it is the same as the original above.

Actual Behaviour

The pipe characters inside code blocks are interpreted as being markdown table columns:

/**
 * | Scenario | Pseudocode | Outcome |
 * | :------- | :--------- | ------- | ---------------------- | --------------------- |
 * | `Ok      |            | Err`    | `pipe(Ok, or(Err))`    | `Ok`                  |
 * | `Err     |            | Ok`     | `pipe(Err, or(Ok))`    | `Ok`                  |
 * | `Err1    |            | Err2`   | `pipe(Err1, or(Err2))` | `Err2`                |
 * | `Ok1     |            | Ok2`    | `pipe(Ok1, or(Ok2))`   | `Ok1` (first Ok wins) |
 */