The table style is determined by the header row. After normalizing the
header (filling empty cells between consecutive delimiters), extract
two properties: the column count and whether the header starts with
a delimiter.
For each data row, normalization proceeds in three steps. First, fill in
empty cells between consecutive delimiters (this handles empty cells in
the middle of a row). Second, if the header has no leading delimiter but
the row does, insert an empty cell after the row's leading delimiter (this
corrects the one-position shift caused by the row having a leading pipe
that the header lacks. Third, if the row has fewer cells than the header
column count, pad with empty cells at the end (this handles rows that
are shorter than the header because trailing pipes or cells were
omitted).
The same normalization is applied both in the renderer and the indexer.
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
The Markdown parser omits `TableCell` nodes for empty cells, so
`collectNodesOfType` returns fewer cells than columns.
The indexer mapped cells to headers by array index, causing all cells
after an empty one to shift left.
The HTML renderer already solved this: its `TableRow` case walks the
children and injects empty `TableCell` nodes between consecutive
`TableDelimiter` nodes with no cell in between.
This patch extracts that same normalization logic into a reusable
`normalizeTableRow` helper and applies it to each row before collecting
cells.
The original index-based cell-to-header mapping then works correctly
without any positional arithmetic. I feel like this is more elegant
solution to the issue.
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
For example, with the following table:
```markdown
| a | b | c |
| --- | --- | --- |
| 1 | | 3 |
| 1 | 2 | 3 |
| a | b | c |
| a | b | |
| | b | c |
| x | | |
| | | z |
```
the following query results in dataset with shifted columns
when cells are empty:
```lua
from
index.tag 'table'
where
page == 'test'
order by
pos asc
select {
a, b, c
}
```
This is now fixed and gives correct results:
|0 |1 |2 |
|--|--|--|
|1 | |3 |
|1 |2 |3 |
|a |b |c |
|a |b | |
| |b |c |
|x | | |
| | |z |
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
* Trim user input from prompts where appropriate
* Run formatter
* Use "page title" language instead of "page name" in notifications.
Existing language in prompt asks for a "page title".
* Use const for prefix inputs as they are never trimmed
- Introduced a new `validate` callback for `tag.define`
- Added `index.validateObjects` API to validate and transform objects before indexing.
- Updated relevant documentation and examples to reflect these changes.
* Modified renamePage function in refactor.ts to ensure navigation to the new page occurs after the index queue is processed, so that linked mentions reflect updated data once arriving there