Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add superfence notation #45

Closed
timvink opened this issue Mar 6, 2023 · 7 comments
Closed

Add superfence notation #45

timvink opened this issue Mar 6, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@timvink
Copy link
Owner

timvink commented Mar 6, 2023

(inspired by this discussion)

Instead of {{ read_csv('table.csv') }} we could take inspiration from https://github.com/coddingtonbear/obsidian-csv-table and create a custom superfences notation like so:

```table-reader
filepath: table.csv
```

We could add the following extra options:

  • reader (str) one of the pandas functions, like read_csv
  • keyword_arguments, a dictionary, with named arguments, for example encoding: 'utf-8'
  • filter (list of strings), where each is successively passed to .query()
  • sortBy (list of strings), passed to pandas's .sort_values()
  • maxRows (int), passed to pandas's .head()
  • columnVariables (list of strings), passed to pandas's .rename()`

You can already do all this by just using a mkdocs hook to preprocess tables.

So if you read this & have a use-case for this, let me know!

@timvink timvink added the question Further information is requested label Mar 6, 2023
@roaldarbol
Copy link

Hey Tim! Original poster of the discussion here.
I might be biased, but I really like the Obsidian notation - the fact that it reads easily, feels void of actual code (which I really prefer in Markdown documents) is a big bonus I think. And the actions/options you listed above should be fine - I would try to match what has been done in the Obsidian plug-in as there is no need to re-invent the wheel, and their users have had a long time to post issues. Thanks for following up on the discussion and with your work on the plugin - I'm looking forward to testing it out!

In terms of a use-case, as I mentioned in the original post, I'm personally working on an open hardware project where we have a collection of parts in a file and want to showcase subsets of parts needed to make each build. :-)

@timvink
Copy link
Owner Author

timvink commented Mar 10, 2023

I really like the Obsidian notation

I thought it would be easier to understand if I would follow the pandas arguments where possible. But it's not that much clearer anyway. Being able to copy markdown from obsidian and have it work in Mkdocs with only minimal changes is more vaiuable.

I'm looking forward to working on this one, but it's low-prio so probably going to take 1-2 months before I have some free time for hobby coding again :D

@timvink timvink added enhancement New feature or request and removed question Further information is requested labels Mar 10, 2023
@roaldarbol
Copy link

No worries, this would be awesome, but not time critical. ;-) Looking forward to your implementation!

@samhodgkinson
Copy link

Was there any progress on this, just hit this issue and looking for a solution to use Marco and table-reader together

@timvink
Copy link
Owner Author

timvink commented Aug 15, 2024

No, however I did solve compatibility between macros and this plugin. See #57. v3 soon to be released.

Update: v3 released: https://pypi.org/project/mkdocs-table-reader-plugin/

@samhodgkinson
Copy link

Thanks for the update on this, much appreciated. @timvink

@timvink
Copy link
Owner Author

timvink commented Aug 27, 2024

I've reconsidered.

I don't want to support an additional format. The reason is compatibility with other plugins, and compatibility with the existing options.

Instead I think there an opportunity for a mkdocs-obsidian-csv-table-plugin. It can re-implement all the options available for https://github.com/coddingtonbear/obsidian-csv-table. That way you would be able to copy paste your obsidian markdown and use it in mkdocs.

I've already solved some tricky problems in this plugin that can be copied:

  • using custom superfences to find and parse the references (Start implementing new superfences notation #53)
  • Storing the current page and making that available to the reader function, so you can find the absolute path from the relative path on a markdown page. See the source code of this plugin.

So if anyone is up for it, go for it!

@timvink timvink closed this as completed Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants