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

WIP: inserting tables with \tableinput command #197

Merged
merged 10 commits into from
Sep 2, 2019
45 changes: 45 additions & 0 deletions docs/src/man/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,51 @@ This is the index then some **markdown** in a side file.

**Note**: if you don't specify a file extension, `.md` is appended to the specified path.

### Inserting a table

You can insert tables directly from CSV files with the `\tableinput{header}{path}` command.
If you generate the file on-the-fly, you should follow this example:
`````judoc
```julia:./tableinput/gen
testcsv = "h1,h2,h3\n152,some string, 1.5f0\n0,another string,2.87"
cserteGT3 marked this conversation as resolved.
Show resolved Hide resolved
write("assets/pages/tableinput/testcsv.csv", testcsv)
```
`````
Then you can insert the table with:
`````judoc
\tableinput{}{./tableinput/testcsv.csv}
`````
Which will result in:

| h1 | h2 | h3 |
| --- | -------------- | ----- |
| 152 | some string | 1.5f0 |
| 0 | another string | 2.87 |

cserteGT3 marked this conversation as resolved.
Show resolved Hide resolved
or if you want to specify the headers:
`````judoc
\tableinput{custom h1, custom h2, custom h3}{./tableinput/testcsv.csv}
`````

| custom h1 | custom h2 | custom h3 |
| --------- | -------------- | --------- |
| 152 | some string | 1.5f0 |
| 0 | another string | 2.87 |

Or you can include an existing CSV file (`assets/test2.csv`):
`````judoc
\tableinput{}{/assets/test2.csv}
`````

!!! note

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:
* The CSV file must have a header line.
cserteGT3 marked this conversation as resolved.
Show resolved Hide resolved
* Columns must be separated with comma (`,`).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with -> by a

* If header is specified, its length must be matched with the table in the file.
cserteGT3 marked this conversation as resolved.
Show resolved Hide resolved

## Page variables

Page variables are a way to interact with the HTML templating.
Expand Down