|
@@ -11,21 +11,26 @@ export type RowPosition = {
|
|
|
hlines: { from: number; to: number }[]
|
|
hlines: { from: number; to: number }[]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function parseColumnSpecifications(specification: string): ColumnDefinition[] {
|
|
|
|
|
|
|
+export function parseColumnSpecifications(
|
|
|
|
|
+ specification: string
|
|
|
|
|
+): ColumnDefinition[] {
|
|
|
const columns: ColumnDefinition[] = []
|
|
const columns: ColumnDefinition[] = []
|
|
|
let currentAlignment: ColumnDefinition['alignment'] | undefined
|
|
let currentAlignment: ColumnDefinition['alignment'] | undefined
|
|
|
let currentBorderLeft = 0
|
|
let currentBorderLeft = 0
|
|
|
let currentBorderRight = 0
|
|
let currentBorderRight = 0
|
|
|
|
|
+ let currentContent = ''
|
|
|
function maybeCommit() {
|
|
function maybeCommit() {
|
|
|
if (currentAlignment !== undefined) {
|
|
if (currentAlignment !== undefined) {
|
|
|
columns.push({
|
|
columns.push({
|
|
|
alignment: currentAlignment,
|
|
alignment: currentAlignment,
|
|
|
borderLeft: currentBorderLeft,
|
|
borderLeft: currentBorderLeft,
|
|
|
borderRight: currentBorderRight,
|
|
borderRight: currentBorderRight,
|
|
|
|
|
+ content: currentContent,
|
|
|
})
|
|
})
|
|
|
currentAlignment = undefined
|
|
currentAlignment = undefined
|
|
|
currentBorderLeft = 0
|
|
currentBorderLeft = 0
|
|
|
currentBorderRight = 0
|
|
currentBorderRight = 0
|
|
|
|
|
+ currentContent = ''
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
for (let i = 0; i < specification.length; i++) {
|
|
for (let i = 0; i < specification.length; i++) {
|
|
@@ -45,18 +50,23 @@ function parseColumnSpecifications(specification: string): ColumnDefinition[] {
|
|
|
}
|
|
}
|
|
|
case 'c':
|
|
case 'c':
|
|
|
currentAlignment = 'center'
|
|
currentAlignment = 'center'
|
|
|
|
|
+ currentContent += 'c'
|
|
|
break
|
|
break
|
|
|
case 'l':
|
|
case 'l':
|
|
|
currentAlignment = 'left'
|
|
currentAlignment = 'left'
|
|
|
|
|
+ currentContent += 'l'
|
|
|
break
|
|
break
|
|
|
case 'r':
|
|
case 'r':
|
|
|
currentAlignment = 'right'
|
|
currentAlignment = 'right'
|
|
|
|
|
+ currentContent += 'r'
|
|
|
break
|
|
break
|
|
|
case 'p': {
|
|
case 'p': {
|
|
|
currentAlignment = 'paragraph'
|
|
currentAlignment = 'paragraph'
|
|
|
|
|
+ currentContent += 'p'
|
|
|
// TODO: Parse these details
|
|
// TODO: Parse these details
|
|
|
while (i < specification.length && specification.charAt(i) !== '}') {
|
|
while (i < specification.length && specification.charAt(i) !== '}') {
|
|
|
i++
|
|
i++
|
|
|
|
|
+ currentContent += specification.charAt(i)
|
|
|
}
|
|
}
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|