-
Notifications
You must be signed in to change notification settings - Fork 115
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
WIP: inserting tables with \tableinput command #197
Conversation
Codecov Report
@@ Coverage Diff @@
## master #197 +/- ##
==========================================
- Coverage 87.21% 84.65% -2.56%
==========================================
Files 26 26
Lines 1087 1121 +34
==========================================
+ Hits 948 949 +1
- Misses 139 172 +33
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #197 +/- ##
==========================================
- Coverage 87.21% 87.03% -0.19%
==========================================
Files 26 26
Lines 1087 1118 +31
==========================================
+ Hits 948 973 +25
- Misses 139 145 +6
Continue to review full report at Codecov.
|
Ok I think your solution is a bit too complicated: Let's say that the file is
Then using DelimitedFiles
content = readdlm("test.csv", ',', String)
open("out.md", "w") do fout
for row in eachrow(content)
write(fout, "| " * prod(e * " | " for e in row))
write(fout, '\n')
end
end Does most of the job (header part missing but it's easy to add). Btw, you may have to write For your question (1) see review comment, just declare the command in For (2), an |
Only reason for this (from the docs):
If the cells in a column doesn't have the same length (like in the followings),
Result markdown:
I didn't tested how the parser handles this kind of table, but in the docs it's stated that they must align, so I would rather align them. |
Here's a bit more code which may help with testing etc: using Markdown
test = """
This is a table:
| a | b | c | d |
| :---: | :---: | :---: | :---: |
| string1 | 1.123 | 2 | 3 |
| string126 | 0.1 | 6 | 7 |
Done.
"""
result = test |> Markdown.parse |> Markdown.html
result = """<style>table, th, td {
border: 1px solid black;
}</style>\n""" * result
write("/Users/tlienart/Desktop/index.html", result) if you open that in a browser you'll get: which is what we want (separators etc are styled in CSS), so you don't need to have things aligned. Note: everything is left-aligned even though there's a specification By the way, JuDoc also uses this |
I'll try to answer everything in this comment. I experienced too, that alignment doesn't matter for the parser, moreover if I'll soon figure out the testing, and write the docs. |
Hey thanks a lot for this, I'll try to look at this tomorrow and get back to you with, hopefully helpful, comments. PS: given that you're one of the first to actually have a look at the code, don't hesitate to also let me know the things that don't make sense and I'll try to add comments (or docs) as appropriate to guide future contributions |
A quick note: |
I've finished the first version of documentation and tests. Let me know if they serve their purpose. PS: This is my first larger PR, so I'm not sure what else should be done (after approving the changes). Rebasing and/or squashing commits? If so, please do let me know, I'd like to do them to practice open source development 😃 . |
Answering to my own issue:
I started writing an MWE and realized that the parser works totally fine. Also I misunderstood what you've written. Now I understand that CSS is dominant. |
Ok, I've added some feedback on "just the code", will now pull your branch, play a bit with it and see if it works as expected, assuming that + fixing of minor comments above, I'll merge. Thanks for contributing! |
Ok it mostly looks good, one more thing though: this test:
looks incorrect; when the header is specified you should not over-write the first line of the CSV file, so the first row after A, B, C should be h1, h2, h3 which is present in the file |
Sorry for the silence, I had a busy week. I've updated the code, tests and documentation (and resolved every review). Please review them particularly the documentation |
| 0 | another string | 2.87 | | ||
In this case given no header was specified in the call, a header was generated from the first line in the CSV (here: h1, h2, h3). | ||
|
||
If you're file doesn't have a header, you can specify it in the call: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're -> your
The look of the table will be defined by your CSS stylesheet. | ||
|
||
There's a couple of rules that you have to keep in mind when using the `\tableinput{}{}` command: | ||
* Columns must be separated with comma (`,`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with -> by a
|
||
There's a couple of rules that you have to keep in mind when using the `\tableinput{}{}` command: | ||
* Columns must be separated with comma (`,`). | ||
* If a header is specified, its length must match the number of columns of the file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of the file -> in the file
looks good to me minus minor nitpicking, thanks a lot for this Tamás! and actually given it's minor, I'll just merge and do it :-) |
As discussed in #195 this PR adds the
\tableinput{header}{path}
command. The current implementation works in the sense that the markdown strings are generated and included in the page. As I see, the followings are need to be done:I need help with the first two tasks (and will do the other two later on):
@assert
is fine, or should just ignore it and write an error message?