| 179 | } |
| 180 | |
| 181 | func resolveDocsTableWithIndex(doc *docs.Document, requested int) (tableWithIndex, int, error) { |
| 182 | tables := collectAllTablesWithIndex(doc) |
| 183 | if len(tables) == 0 { |
| 184 | return tableWithIndex{}, 0, usage("document has no tables") |
| 185 | } |
| 186 | idx := requested |
| 187 | if idx < 0 { |
| 188 | idx = len(tables) + idx + 1 |
| 189 | } |
| 190 | if idx < 1 || idx > len(tables) { |
| 191 | return tableWithIndex{}, 0, usagef("table %d out of range (document has %d tables)", requested, len(tables)) |
| 192 | } |
| 193 | return tables[idx-1], idx, nil |
| 194 | } |
| 195 | |
| 196 | func docsTableColumnCount(table *docs.Table) int { |
| 197 | if table == nil { |