-
Notifications
You must be signed in to change notification settings - Fork 9
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
[ FEATURE ] Format #table in a human readable way #59
Comments
tracking in #17 |
The initial idea is to match patterns like We may put n cells in a line if they can fit in a line. Otherwise we spread them into multiple lines.(This still doesn't sounds good. Do you have better ideas? |
Maybe indent the leftover ones a bit?
Also maybe try to include |
colspan, rowspan and cell will very likely to be not supported in the initial MVP. But i think it can be supported once we have a good framework to deal with normal tables |
If there is any span element (e.g. I paste three table formatting here that looks beautiful imo:
2 multiple line with parbreak separated:
3 simulate the header's shape:
|
Currently i have implement table format if a table:
|
i'm going to support header/footer/vline/hline in the next step |
I think the limitation can be somehow loosed to follows:
This allows header/footer usage, which will possibly help #78(Although the author doesn't provide their code yet). To format them, we can put header/footer in a single line. |
Another way is that for table, we only format each args and don't change newlines, so user can freely arrange their cells. This can be a fallback code path. |
Inspired by https://typst.app/universe/package/pillar's string command, we may have some general macro to hint formatting to call, which could also be the intermediate structure between smart formatters and the base formatter.
// @typstyle:call-group=4|4+,{1,_,2},4
// `|`: a line caused by the mid line in `call-group` macro
// `4+`: multiple arguments are group by 4.
#table([],[],[],[], [],[],[],[], [],[],[], [],[],[],[]) is formatted as: // @typstyle:call-group=4|4+,{1,_,2},4
#table(
[],[],[],[],
[],[],[],[],
[], [],[],
[],[],[],[],
)
struct SmartFormatter;
impl SmartFormatter {
fn identify_dsl_calls(input: Input) -> ResultMap {
let res = ResultMap::default();
res.insert(LineCol(2, 0), "4|4+,{1,_,2},4");
res
}
} An easy but powerful format is required by this approach tho. |
implemented in #90 |
astrale-sharp/typstfmt#170 (comment)
Would it be possible to format tables in a way that makes since while reading them ?
example
The text was updated successfully, but these errors were encountered: