Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/OrangeX4/typst-tablem
Write markdown-like tables easily.
https://github.com/OrangeX4/typst-tablem
Last synced: 3 months ago
JSON representation
Write markdown-like tables easily.
- Host: GitHub
- URL: https://github.com/OrangeX4/typst-tablem
- Owner: OrangeX4
- License: mit
- Created: 2023-11-15T08:08:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-08T11:06:05.000Z (10 months ago)
- Last Synced: 2024-10-03T12:40:03.597Z (4 months ago)
- Language: Typst
- Size: 43.9 KB
- Stars: 38
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-typst - typst-tablem - Write markdown-like tables easily. (Templates & Libraries / Formatting)
README
# Tablem
Write markdown-like tables easily.
## Example
Have a look at the source [here](./examples/example.typ).
![Example](./examples/example.png)
## Usage
You can simply copy the markdown table and paste it in `tablem` function.
```typ
#import "@preview/tablem:0.1.0": tablem#tablem[
| *Name* | *Location* | *Height* | *Score* |
| ------ | ---------- | -------- | ------- |
| John | Second St. | 180 cm | 5 |
| Wally | Third Av. | 160 cm | 10 |
]
```And you can use custom render function.
```typ
#import "@preview/tablem:0.1.0": tablem#let three-line-table = tablem.with(
render: (columns: auto, ..args) => {
table(
columns: columns,
stroke: none,
align: center + horizon,
table.hline(y: 0),
table.hline(y: 1, stroke: .5pt),
..args,
table.hline(),
)
}
)#three-line-table[
| *Name* | *Location* | *Height* | *Score* |
| ------ | ---------- | -------- | ------- |
| John | Second St. | 180 cm | 5 |
| Wally | Third Av. | 160 cm | 10 |
]
```![Example](./examples/example.png)
## `tablem` function
```typ
#let tablem(
render: table,
ignore-second-row: true,
..args,
body
) = { .. }
```**Arguments:**
- `render`: [`(columns: int, ..args) => { .. }`] — Custom render function, default to be `table`, receiving a integer-type columns, which is the count of first row. `..args` is the combination of `args` of `tablem` function and children genenerated from `body`.
- `ignore-second-row`: [`boolean`] — Whether to ignore the second row (something like `|---|`).
- `args`: [`any`] — Some arguments you want to pass to `render` function.
- `body`: [`content`] — The markdown-like table. There should be no extra line breaks in it.## Limitations
Cell merging has not yet been implemented.
## License
This project is licensed under the MIT License.