Sortable Tables

Adding a new Markdown command to allow a table to be sorted by clicking on its column headings.

Here is the draft description:

As an extension to the original Markdown spec from John Gruber, a Markdown Table may be made sortable by preceding it with the literal {:sort-table:xxx} on a line by itself (where ‘xxx’ is replaced by the id value to be assigned to the table, as in the following example:

{:sort-table: ideas-table}

This command will inject JavaScript into the resulting HTML page, allowing the viewer to click on any table heading in order to sort the table by the values in that column.

Numbers will be sorted numerically.

Other values will be sorted by their alpha values, ignoring case (upper- or lower).

Clicking again on a column will reverse the sort, so that values appear in descending sequence.

This is planned for 11.6.0.

Let me know if questions or comments, or if you would like me to make a beta version available for testing.

1 Like

This command will inject JavaScript into the resulting HTML page, allowing the viewer to click on any table heading in order to sort the table by the values in that column.

I think that this is a nifty idea. For a long time I’ve contemplated making a post that entertained the possibility of using Javascript as a way to extend the capabilities of Notenik. The fact that Notenik operates so closely to HTML and CSS makes it relatively trivial for a “plugin” sort of ecosystem to develop naturally. Most importantly, I can imagine that this ecosystem can be cultivated without having to make any changes to Notenik’s actual code.

I don’t currently have any use cases for sortable tables right now, but I what I support the most is how the command functions and the promise that its addition can bring to the app in the long term from a developmental perspective and for users as well.

Interesting comment. I wonder if there are other cases where Javascript “plugins” could add useful functionality?

I think that most use cases would be more cosmetic than anything, not unlike how sortable tables work. A have no Javascript experience, so I’m more an idealist in this respect. Nonetheless, I can imagine that there can be a way for libraries like pdf.js to be used to render PDFs in a Notenik collection. Folk (Browser) Interfaces is an article that introduced some interesting concepts to me about novel ways of using Javascript.

On second thought, I think that something like what I’m describing may be more suited for work outside of Notenik itself. Depending on the size of the Javascript code things may become disruptive.

All in all, I’m not imagining anything similar to the vast ecosystem that Obsidian offers. It has an advantage in this area by way of being an Electron app, a fact that in itself may be regarded as a disadvantage to some. In order to really grasp the usefulness of Javascript within a Notenik collection, I would probably have to understand the language and its relationship to web-like interfaces in a way similar to how it’s approached in the above article.

I don’t want to come across as long-winded and I may be totally naive to how things work practically, but I reckon that Javascript is not the only language that can interact with a Notenik collection. PHP may have some promise in this area also.

I can go on. These are just enthusiastic ramblings, but there may be a kernel of promise hidden within them. If what I’m saying is of any intrigue…then, thank you for beautiful work.

1 Like