@@ -888,7 +888,7 @@ private fun EagerComposer.tableColFirst(
888
888
.filter {
889
889
it.tagName() in setOf (" th" , " td" )
890
890
}.count()
891
- }.max()
891
+ }.maxOrNull() ? : 0
892
892
}
893
893
}
894
894
@@ -952,58 +952,60 @@ private fun EagerComposer.tableColFirst(
952
952
}
953
953
954
954
key(rowCount, colCount, rowData, baseUrl, onLinkClick) {
955
- LazyRow (
956
- horizontalArrangement = Arrangement .spacedBy(32 .dp),
957
- modifier = Modifier
958
- .horizontalScroll(rememberScrollState())
959
- .width(dimens.maxReaderWidth),
960
- ) {
961
- items(
962
- count = colCount,
963
- ) { colIndex ->
964
- Column (
965
- verticalArrangement = Arrangement .spacedBy(4 .dp),
966
- modifier = Modifier ,
967
- ) {
968
- for (rowIndex in 0 until rowCount) {
969
- val (section, rowElement) = rowData.getOrNull(rowIndex) ? : break
970
- var emptyCell = false
971
- Surface (
972
- tonalElevation = when (section) {
973
- " thead" -> 3 .dp
974
- " tbody" -> 0 .dp
975
- " tfoot" -> 1 .dp
976
- else -> 0 .dp
977
- },
978
- ) {
979
- rowElement.children()
980
- .filter { it.tagName() in setOf (" th" , " td" ) }
981
- .elementAtOrNullWithSpans(colIndex)
982
- ?.let { colElement ->
983
- withParagraph {
984
- withStyle(
985
- if (colElement.tagName() == " th" ) {
986
- SpanStyle (fontWeight = FontWeight .Bold )
987
- } else {
988
- null
989
- },
990
- ) {
991
- appendTextChildren(
992
- colElement.childNodes(),
993
- baseUrl = baseUrl,
994
- onLinkClick = onLinkClick,
995
- keyHolder = keyHolder,
996
- )
955
+ if (rowCount > 0 && colCount > 0 ) {
956
+ LazyRow (
957
+ horizontalArrangement = Arrangement .spacedBy(32 .dp),
958
+ modifier = Modifier
959
+ .horizontalScroll(rememberScrollState())
960
+ .width(dimens.maxReaderWidth),
961
+ ) {
962
+ items(
963
+ count = colCount,
964
+ ) { colIndex ->
965
+ Column (
966
+ verticalArrangement = Arrangement .spacedBy(4 .dp),
967
+ modifier = Modifier ,
968
+ ) {
969
+ for (rowIndex in 0 until rowCount) {
970
+ val (section, rowElement) = rowData.getOrNull(rowIndex) ? : break
971
+ var emptyCell = false
972
+ Surface (
973
+ tonalElevation = when (section) {
974
+ " thead" -> 3 .dp
975
+ " tbody" -> 0 .dp
976
+ " tfoot" -> 1 .dp
977
+ else -> 0 .dp
978
+ },
979
+ ) {
980
+ rowElement.children()
981
+ .filter { it.tagName() in setOf (" th" , " td" ) }
982
+ .elementAtOrNullWithSpans(colIndex)
983
+ ?.let { colElement ->
984
+ withParagraph {
985
+ withStyle(
986
+ if (colElement.tagName() == " th" ) {
987
+ SpanStyle (fontWeight = FontWeight .Bold )
988
+ } else {
989
+ null
990
+ },
991
+ ) {
992
+ appendTextChildren(
993
+ colElement.childNodes(),
994
+ baseUrl = baseUrl,
995
+ onLinkClick = onLinkClick,
996
+ keyHolder = keyHolder,
997
+ )
998
+ }
997
999
}
998
1000
}
999
- }
1000
- emptyCell = ! render()
1001
- }
1002
- if (emptyCell) {
1003
- // An empty cell looks better if it has some height - but don't want
1004
- // the surface because having one space wide surface is weird
1005
- append( ' ' )
1006
- render()
1001
+ emptyCell = ! render()
1002
+ }
1003
+ if (emptyCell) {
1004
+ // An empty cell looks better if it has some height - but don't want
1005
+ // the surface because having one space wide surface is weird
1006
+ append( ' ' )
1007
+ render( )
1008
+ }
1007
1009
}
1008
1010
}
1009
1011
}
0 commit comments