subroutinerow_cellsprivate
subroutine row_cells(line, cells)
The cells of a table row, split at | outside code spans.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| line | character(len=*) | in | the row | |
| cells | type(string_t) | out | allocatabledimension(:) | the cells |
Calls
Source
Show the code
subroutine row_cells(line, cells)
character(len=*), intent(in) :: line !! the row
type(string_t), allocatable, intent(out) :: cells(:) !! the cells
character(len=:), allocatable :: row
logical :: in_code
integer :: k, start
row = strip(line)
if (starts_with(row, '|')) row = row(2:)
if (ends_with(row, '|') .and. .not. ends_with(row, '\|')) row = row(:len(row) - 1)
allocate (cells(0))
in_code = .false.
start = 1
k = 1
do while (k <= len(row))
select case (row(k:k))
case ('`')
in_code = .not. in_code
case ('\')
k = k + 1
case ('|')
if (.not. in_code) then
call push(cells, strip(row(start:k - 1)))
start = k + 1
end if
end select
k = k + 1
end do
call push(cells, strip(row(start:)))
end subroutine row_cells