Plugin: Markdown Table Formatter

(!) The plugin will only be available in 1.8

This plugin helps to keep your markdown tables nice and tidy. Just put the cursor anywhere within a table and click Edit - Format Table.

This is only for the editor, it does not change the rendered markdown (at least it's not supposed to).

Source code: GitHub - roman-r-m/joplin-plugin-table-formatter: Markdown table format plugin for Joplin



Nice, unfortunately it doesn't work with how I write tables:

head1 | head2 | head3
col1 |col2 |col3
col1 |col2 |col3

P.S.: And for me the menu item is actually in Edit and not Note.

Sadly, I can't get it to work, even with the example in the gif, I get Uncaught (in promise) Error: Command not found: editor.execCommand. Make sure the declaration has been registered. in the console. Am I missing something obvious? Using Joplin 1.7.11 win32 (portable).
(the menu option is also in Edit > Format Table for me).

One thing I like in my tables is to have at least one space before and after each value, like | col1 | and not just |col1|. Any chance this could be added?

This what happens when you stay up late to finish things up. Thanks, I'll update the top post.

As for this, right now the plugin assumes that each line must start with a pipe as this was the easiest thing to do.
I'll implement a more sophisticated parser in the next version.

1 Like

Right, looks like it relies on a change that is not yet available even in pre-releases. I'll update the manifest and we'll have to wait for the next version, sorry.

Hi Roman
Thanks for your great plguins.
Unfortunately I couldn't install this one
I'm using portable version 1.7.11 on Win 10
When searching for it from the app it shows a card with the name of the plubin and beneath it a message 'Please upgrade Joplin to use this plugin
Checking updategives me a message 'version is up to date'
Am i missing somehting?

Hi Osman

Unfortunately the plugin relies on functionality that is not available even in pre-releases at this point. I have not noticed it as I was testing against dev version.
We have to wait for the next release.

Oh! no problem then.. it worth waiting.
Thanks for your prompt replay.

No problem, I figured that was the case, I saw some other plugins only compatible with 1.8. I now have the 'Please update Joplin to use this plugin' message.

In any case, I am really looking forward to this plugin, I have a lot of tables in my notes and I had to spend quite a bit of time to correct the formatting a couple days ago.

Maybe I should just use the table format that is supported. I think it is required anyway, if one wants to do left/right/center alignment in columns.
I just have to get used to it that's all. I can change my existing tables over time.

I wouldn't be too unhappy about support for "my" table format either. But if it makes the parser too complex it might not be worth it.

Me too. But it could be beneficial to use a compact format as well. This is very subjective and depends on people's preference.

It could be added via an option though. If roman_r_m is ok with it, I can create a PR for it. (Not right now, but when I have a bit more time.)

1 Like

Sure, go for it. Maybe I'll get to it too, but first I want to see if I can make the plugin work on the latest released version.

@roman_r_m you might be interested in the prettier code formatter. I had originally written a "Prettify Selection" command into my rich markdown plugin, but unfortunately it does not work on the current version, so it's been commented out for awhile. You can see the code I used here.

In any case I think that kind of functionality is probably better in a separate plugin. If you're interested I think it would be great to combine the prettier tool with your plugin. I'd be happy to help contribute as well if you'd like.

1 Like

Thanks Caleb. I had a look at the prettier lib and looks like it's all I need, it already seems to have MD table formatter built-in.
I'll give it a try over the next few days. Contributions are always welcome of course.


Now that Joplin 1.8 is (pre-)released the plugin should be available for download.

1 Like

Hi nice plugin, however it breaks when left/right/center column alignment is used. Not a huge deal to rectify manually but thought I'd mention if it's able to be fixed. Thanks again.

1 Like

Hmm...seems to work fine for me. I use the basic colon formatting like this:

| Column 1 | Column 2   |
| Foo      | Bar        |
| Foo      | Bar        |

I've assigned a hotkey to the "Format Table" menu option so, after making table changes, I press the hotkey, and the text table appears to be formatted properly. Are you doing something differently?

Do you have an example?

Here you go, thanks for taking a look. I have Tabs plugin but see the same result with Tabs disabled. Also see the same result with the line break removed. Any issues with my formatting?

I should mention I'm using Windows portable v1.8.5

1 Like

So why not use prettier? Or use a more primitive remark for parsing. You only need to deal with alignment issues. There is no need to recreate the wheels of the markdown parser.

The effect is as follows

you will see

  • The table is formatted
  • Non-standard + is treated as -, * is treated as _
  • The missing blank lines are filled in, and the extra blank lines are deleted
  • Wrong ordered list was corrected
  • The code is formatted correctly

I mentioned a PR on GitHub, but it should be noted that since I do not use Joplin’s built-in editor So it didn’t deal with details, including

  • Only format the selected part when selected
  • The cursor position before and after formatting should be consistent
  • Support right click, toolbar or use shortcut keys to format