~toasterking/scdoc2mdoc

992fb2194239421249776b7306abe24ba88f9cb3 — Drew DeVault 8 months ago fb25a65 master
tables: add expand options
2 files changed, 49 insertions(+), 2 deletions(-)

M parser.c
M scdoc.5.scd
M parser.c => parser.c +34 -2
@@ 410,6 410,9 @@ enum table_align {
	ALIGN_LEFT,
	ALIGN_CENTER,
	ALIGN_RIGHT,
	ALIGN_LEFT_EXPAND,
	ALIGN_CENTER_EXPAND,
	ALIGN_RIGHT_EXPAND,
};

struct table_row {


@@ 484,6 487,15 @@ parse_table(struct parser *p, uint32_t style)
		case ']':
			curcell->align = ALIGN_RIGHT;
			break;
		case '<':
			curcell->align = ALIGN_LEFT_EXPAND;
			break;
		case '=':
			curcell->align = ALIGN_CENTER_EXPAND;
			break;
		case '>':
			curcell->align = ALIGN_RIGHT_EXPAND;
			break;
		case ' ':
			if (prevrow) {
				struct table_cell *pcell = prevrow->cell;


@@ 549,8 561,28 @@ commit_table:
	while (currow) {
		curcell = currow->cell;
		while (curcell) {
			printf("%c%s", "lcr"[curcell->align],
				curcell->next ? " " : "");
			char *align = "";
			switch (curcell->align) {
			case ALIGN_LEFT:
				align = "l";
				break;
			case ALIGN_CENTER:
				align = "c";
				break;
			case ALIGN_RIGHT:
				align = "r";
				break;
			case ALIGN_LEFT_EXPAND:
				align = "lx";
				break;
			case ALIGN_CENTER_EXPAND:
				align = "cx";
				break;
			case ALIGN_RIGHT_EXPAND:
				align = "rx";
				break;
			}
			printf("%s%s", align, curcell->next ? " " : "");
			curcell = curcell->next;
		}
		puts(currow->next ? "" : ".");

M scdoc.5.scd => scdoc.5.scd +15 -0
@@ 155,6 155,21 @@ To conclude your table, add an empty line after the last row.
:  世界
   !

You may also cause columns to expand to fill the available space with < (left
align), = (center align), and > (right align), like so:

```
[[ *Normal column*
:< Expanded column
|  *Foo*
:  Bar
```

[[ *Normal column*
:< Expanded column
|  *Foo*
:  Bar

## LITERAL TEXT

You may turn off scdoc formatting and output literal text with escape codes and