redbug312 / markdown-it-multimd-table

Multimarkdown table syntax plugin for markdown-it markdown parser
MIT License
146 stars 37 forks source link

Vscode auto format more | when using Multiline #23

Closed harrytran998 closed 4 years ago

harrytran998 commented 4 years ago

@RedBug312 , here this format after Vscode automatically formatted:

|     A1      | A2  | B1  | B2  |           C1            | C2  |
| :---------: | :-: | :-: | :-: | :---------------------: | :-: |
| appropriate |  a  |  a  |  a  |   - appropriately adv   |     | \ |
|             |     |     |     | - inappropriate neg adj |     |

And this is the result: image

But how can use it like your README.md but do not disable VSCode's formatOnSave for markdown file? (Sorry, I'm a newbie)

redbug312 commented 4 years ago

Thanks for the report. This plugin can't do anything to modification by editors/IDEs, since semantic meanings have changed after auto-formatting. A better solution is to configure VSCode formatter; to avoid trailing \ from recognizing as another table cell. Can you provide the code before formatting, and the formatter you're using?

harrytran998 commented 4 years ago

Thanks for the report. This plugin can't do anything to modification by editors/IDEs, since semantic meanings have changed after auto-formatting. A better solution is to configure VSCode formatter; to avoid trailing \ from recognizing as another table cell. Can you provide the code before formatting, and the formatter you're using?

Sorry for the reply too late 😅. I'm just using this config:

// Config markdown
  "[markdown]": {
    "editor.fontFamily": "Menlo, Monaco, 'Courier New', monospace",
    "editor.formatOnSave": true
  },

And installed plugins: Prettier and Markdown Shortcuts of mdickin

redbug312 commented 4 years ago

Prettier does the markdown auto-formatting. But there's no option for this feature, and I guess they won't add the option in the future.

First, trailing \ is out of most Markdown specs (CommonMark and GFM that prettier adopts; even MultiMarkdown itself). Also, from the docs, no extensions supported; and few options are carefully chosen. It seems no reason for them to break their principle to include an uncommon feature.

Either you can turn to another more expressive formatter, or you can use the workaround that flags the whole paragraph (table) to be ignored:

<!-- prettier-ignore -->
|     A1      | A2  | B1  | B2  |           C1            | C2  |
| :---------: | :-: | :-: | :-: | :---------------------: | :-: |
| appropriate |  a  |  a  |  a  |   - appropriately adv   |     | \
|             |     |     |     | - inappropriate neg adj |     |

You can see the playground result here.

harrytran998 commented 4 years ago

@RedBug312 Thanks bro, it's worked! Yeah, and happy new year 🥳!