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

Inserting tables [WIP] #195

Closed
cserteGT3 opened this issue Aug 7, 2019 · 4 comments
Closed

Inserting tables [WIP] #195

cserteGT3 opened this issue Aug 7, 2019 · 4 comments
Labels

Comments

@cserteGT3
Copy link
Contributor

PS

When I was initially working on these insertion commands, I thought it could be useful to have something for automatic table insertions, for instance if a table was generated by a script and then it would be formatted nicely in markdown. It sounds like this may be what you're trying to do. If so and if you'd be interested in this, maybe open another issue and we can work through it? (I reckon it would be a simple PR if you're feeling adventurous)

Originally posted by @tlienart in #193 (comment)

I'm curious about your idea and happy to contribute to your work!

@tlienart
Copy link
Owner

tlienart commented Aug 7, 2019

Nice!

Well I guess there could be several ways of doing this but the idea was:

  1. user has some CSV file, possibly with headers, (e.g. CSV file was generated)
  2. there's a command \tableinput{}{...} which reads such a CSV file and inserts formatted markdown.

The first {} could correspond to a header specification e.g. col1, col2, col3 or empty if to be deduced from the file.
The second {} would contain the path to the file.

For the command, you could mimick the function resolve_lx_figalt in src/converter/lx_simple.jl and define a simpler resolve_lx_tableinput.

Then you need to add it to the dictionary LXCOM_SIMPLE in the same file and indicate that it's a default command in def_GLOBAL_LXDEFS! in src/jd_vars.jl

(I reckon if you just grep for figalt and mimick the behaviour adapting for a table input instead of a figure, it should more or less guide you).

@tlienart tlienart added enhancement New feature or request good first issue labels Aug 7, 2019
@cserteGT3
Copy link
Contributor Author

Here's couple of my thoughts (after diving into the package's code):

  1. We should decide, if we want CSV.jl as dependency. It's doable with readdlm(), but I guess it will be more restrictive (one example: the header is decided by the user OR from the CSV file, the user can not override the header in the file). For me it's fine either way, though readdlm() would be more work (which is also more fun I guess 😄 ). Also I didn't have an MWE to state these things.

  2. resolve_lx_tableinput should generate what? Html or markdown that is then passed to another function (which I didn't find yet) which parses it to html?

  3. Would be nice to have a 3rd argument where the user can specify the alignment (after we've got a working version of the basic functionality).

@tlienart
Copy link
Owner

tlienart commented Aug 8, 2019

  1. I think initially just go with DelimitedFiles (and readdlm), the move to CSV.jl would not be too hard afterwards assuming it's relevant :) but I mean I don't think it's relevant to have a huge machinery here, we'd be talking about small tables after all, like 10x5 max.
  2. it should generate markdown for a table so things like | ... | ... | (it will be reparsed and converted to html by the markdown parser later)
  3. hmm yeah, I'm a bit reluctant to have too many braces floating around; this kind of suggests to start thinking about a machinery for options like \command[options]{...} but that's not trivial

Alternatively, the user could just pass the full header itself so all three would be valid:

  • \tableinput{}{path/to/file.csv} (inferred header from first line, left alignment)
  • \tableinput{col1, col2, col3}{path/to/file.csv} (header is | col1 | ... left alignment)
\tableinput{
| col1 | col2 | col3 |
| :---: | :---: | :---: |}{path/to/file.csv}

But I think just do the basic one for now. Also I'm not sure Julia's Markdown to HTML takes into account alignment if it's given.

@tlienart tlienart changed the title Inserting tables Inserting tables [WIP] Sep 1, 2019
@tlienart tlienart added the wip label Sep 1, 2019
@tlienart
Copy link
Owner

tlienart commented Sep 5, 2019

Closing this thanks to #197 🎉

@tlienart tlienart closed this as completed Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants